本文整理汇总了Golang中butler/null.GetString函数的典型用法代码### 示例。如果您正苦于以下问题:Golang GetString函数的具体用法?Golang GetString怎么用?Golang GetString使用的例子?那么恭喜您, 这里精选的函数代码### 示例或许可以为您提供帮助。

在下文中一共展示了GetString函数的20个代码### 示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码### 示例。

示例1: resolveHeader

func (pkg *Package) resolveHeader(function *tp.Function) {
    returnType := null.GetString(function.ReturnType)
    if len(returnType) > 0 {
        function.ReturnTypeId = proto.Int32(int32(pkg.findTypeIndex(returnType)))
        function.ReturnType = nil
    }

    scopeType := null.GetString(function.ScopeType)
    if len(scopeType) > 0 {
        function.ScopeTypeId = proto.Int32(int32(pkg.findTypeIndex(scopeType)))
        function.ScopeType = nil
    }

    opensType := null.GetString(function.OpensType)
    if len(opensType) > 0 {
        function.OpensTypeId = proto.Int32(int32(pkg.findTypeIndex(opensType)))
        function.OpensType = nil
    }

    for _, arg := range function.Args {
        typeName := null.GetString(arg.TypeString)
        if len(typeName) > 0 {
            arg.TypeId = proto.Int32(int32(pkg.findTypeIndex(typeName)))
            arg.TypeString = nil
        }
    }
}

开发者ID:nmakiya,项目名称:tritium,代码行数:27,代码来源:resolve.go

示例2: Write

func (m *Mixer) Write(path string) (outputPath string, err error) {

    name := null.GetString(m.Name)
    version := null.GetString(m.Version)
    outputPath = filepath.Join(path, name+"-"+version+".mxr")

    bytes, err := pb.Marshal(m)
    if err != nil {
        return
    }

    bytes = crypto.Encrypt(bytes)

    err = os.MkdirAll(path, fileutil.DIR_PERMS)
    if err != nil {
        return
    }

    err = ioutil.WriteFile(outputPath, bytes, fileutil.FILE_PERMS)
    if err != nil {
        return
    }

    return
}

开发者ID:nmakiya,项目名称:tritium,代码行数:25,代码来源:mixer.go

示例3: Merge

func (pkg *Package) Merge(otherPackage *tp.Package) {

    if otherPackage == nil {
        return
    }

    //// Reflection would make this code cleaner:

    var existingTypeId int

    for _, someType := range otherPackage.Types {
        existingTypeId = pkg.GetTypeId(null.GetString(someType.Name))
        if existingTypeId == -1 {
            pkg.Types = append(pkg.Types, someType)
        }
    }

    for _, function := range otherPackage.Functions {

        if null.GetBool(function.BuiltIn) {
            pkg.resolveHeader(function)
        } else {
            resolveDefinition(pkg.Package, function, "")
        }
        pkg.Package.Functions = append(pkg.Package.Functions, function)
    }

    for _, dependency := range otherPackage.Dependencies {
        pkg.Dependencies = append(pkg.Dependencies, dependency)
    }

    otherName := null.GetString(otherPackage.Name)
    pkg.Dependencies = append(pkg.Dependencies, otherName)
    pkg.Log.Infof("Added dependency (" + otherName + ") to " + null.GetString(pkg.Name) + "'s loaded dependencies")
}

开发者ID:nmakiya,项目名称:tritium,代码行数:35,代码来源:output.go

示例4: ancestralFuncStub

func ancestralFuncStub(pkg *tp.Package, fun *tp.Function) *string {
    foundAncestor := false

    name := null.GetString(fun.Name)
    args := ""
    for _, arg := range fun.Args {
        argType := null.GetInt32(arg.TypeId)
        ancestralArgType := FindAncestralType(pkg, argType)

        if ancestralArgType != -1 {
            foundAncestor = true
            argType = ancestralArgType
        }

        argTypeString := pkg.GetTypeName(argType)

        argName := argTypeString
        argName = argName + " %" + null.GetString(arg.Name)
        args = args + ", " + argName
    }
    if len(args) > 1 {
        args = args[2:]
    }

    returnType := null.GetInt32(fun.ReturnTypeId)
    ancestralReturnType := FindAncestralType(pkg, returnType)

    if ancestralReturnType != -1 {
        foundAncestor = true
        returnType = ancestralReturnType
    }

    returnTypeString := pkg.GetTypeName(returnType)
    returnVal := name + "(" + args + ") " + returnTypeString + " "

    opensType := null.GetInt32(fun.OpensTypeId)
    ancestralOpensType := FindAncestralType(pkg, opensType)

    if ancestralOpensType != -1 {
        foundAncestor = true
        opensType = ancestralOpensType
    }

    opensTypeString := pkg.GetTypeName(opensType)

    if opensTypeString != "Base" {
        returnVal = returnVal + opensTypeString
    }

    if foundAncestor {
        return &returnVal
    }
    return nil

}

开发者ID:nmakiya,项目名称:tritium,代码行数:55,代码来源:doc.go

示例5: BuildMixer

func BuildMixer(buildPath string, name string, dataPath string) *Mixer {
    rawPath, err := findInBuildPath(buildPath, name)

    if err != nil {
        panic(err.Error())
    }

    path := *rawPath

    raw_mixer := tp.NewMixer(filepath.Clean(path))
    mixer := &Mixer{
        Mixer:          raw_mixer,
        LibraryPath:    buildPath,
        DefinitionPath: path,
        DataPath:       dataPath,
    }
    // println("func BuildMixer")
    // println("build path:", buildPath)
    // println("definition path:", path)
    // println()

    rewritersDirectory := filepath.Join(path, "/rewriters")
    mixer.Rewriters = tp.CollectFiles(rewritersDirectory)

    packageDirectory := filepath.Join(path, "/package")
    mixer.RootPackage = NewRootPackage(packageDirectory, null.GetString(mixer.Name), dataPath)

    mixer.loadDependentMixers()

    error := BuildRootPackage(mixer.RootPackage, packageDirectory, null.GetString(mixer.Name))

    if error == nil {
        //mixer.RootPackage = pkg
        // Now that we're done resolving, slice off the members! (Ouch)
        mixer.Package = mixer.RootPackage.Package

    } else if error.Code != NOT_FOUND {
        //TODO : Put this into a debug log
        panic(error.Message)
    }

    versionFile := filepath.Join(mixer.DefinitionPath, "..", "..", "JENKINS")
    buildNumber, err := ioutil.ReadFile(versionFile)

    if err == nil {
        mixer.Version = proto.String(null.GetString(mixer.Version) + "." + strings.Trim(string(buildNumber), "\n\r "))
    }

    return mixer
}

开发者ID:nmakiya,项目名称:tritium,代码行数:50,代码来源:mixer.go

示例6: CheckForLocationExport

func (result *CheckResult) CheckForLocationExport(script *tp.ScriptObject) {
    iterate(script, func(ins *tp.Instruction) {
        if *ins.Type == constants.Instruction_FUNCTION_CALL {
            name := null.GetString(ins.Value)
            if name == "export" {
                if ins.Arguments != nil {
                    if null.GetString(ins.Arguments[0].Value) == "location" {
                        result.AddScriptWarning(script, ins, "Incorrect export of location! Use \"Location\" not \"location\"")
                    }
                }
            }
        }
    })
}

开发者ID:nmakiya,项目名称:tritium,代码行数:14,代码来源:checks.go

示例7: ShortFuncStub

func ShortFuncStub(pkg *tp.Package, fun *tp.Function) string {
    name := null.GetString(fun.Name)
    args := ""
    for _, arg := range fun.Args {
        t := pkg.Types[int(null.GetInt32(arg.TypeId))]
        argName := null.GetString(t.Name)
        argName = argName
        args = args + ", " + argName
    }
    if len(args) > 1 {
        args = args[2:]
    }
    returnVal := name + "(" + args + ")"
    return returnVal
}

开发者ID:nmakiya,项目名称:tritium,代码行数:15,代码来源:doc.go

示例8: BaseSignature

func (f *Function) BaseSignature(pkg2 protoface.Package) string {
    pkg := pkg2.(*Package)
    args := "("
    for i, arg := range f.Args {
        argName := null.GetString(arg.TypeString)
        if argName == "" {
            t := pkg.Types[int(null.GetInt32(arg.TypeId))]
            argName = null.GetString(t.Name)
        }
        if i != 0 {
            args += ","
        }
        args += argName
    }
    return fmt.Sprintf("%s.%s%s)", pkg.GetTypeName(f.GetScopeTypeId()), f.GetName(), args)
}

开发者ID:nmakiya,项目名称:tritium,代码行数:16,代码来源:function.go

示例9: GetTypeId

func (pkg *Package) GetTypeId(name string) int {
    for id, typ := range pkg.Types {
        if null.GetString(typ.Name) == name {
            return id
        }
    }
    return -1
}

开发者ID:nmakiya,项目名称:tritium,代码行数:8,代码来源:package.go

示例10: Stub

func (f *Function) Stub(pkg2 protoface.Package) string {
    pkg := pkg2.(*Package)
    ns := f.GetNamespace()
    if len(ns) == 0 {
        ns = "tritium"
    }
    fname := fmt.Sprintf("%s.%s", ns, f.GetName())
    args := ""
    for _, arg := range f.Args {
        argName := null.GetString(arg.TypeString)
        if argName == "" {
            t := pkg.Types[int(null.GetInt32(arg.TypeId))]
            argName = null.GetString(t.Name)
        }
        args = args + "," + argName
    }
    return fname + args
}

开发者ID:nmakiya,项目名称:tritium,代码行数:18,代码来源:function.go

示例11: CheckForSelectText

func (result *CheckResult) CheckForSelectText(script *tp.ScriptObject) {
    tester := MustCompile("([^\\[\\(^]|^)(text|comment)\\(\\)([^=]|$)")
    iterate(script, func(ins *tp.Instruction) {
        if *ins.Type == constants.Instruction_FUNCTION_CALL {
            name := null.GetString(ins.Value)
            if name == "$" || name == "select" || name == "move_here" || name == "move_to" || name == "move" {

                for _, arg := range ins.Arguments {
                    xpath := null.GetString(arg.Value)
                    if tester.Match([]byte(xpath)) {
                        result.AddScriptWarning(script, ins, "Shouldn't use comment()/text() in '"+xpath+"'")
                    }
                }
            }
        }

    })
}

开发者ID:nmakiya,项目名称:tritium,代码行数:18,代码来源:checks.go

示例12: Inspect

func (m *Mixer) Inspect(printFunctions bool) {
    println("\tRewriters:")
    for _, rewriter := range m.Rewriters {
        fmt.Printf("\t\t -- %v\n", null.GetString(rewriter.Path))
    }

    println("\tRoot Package:")
    fmt.Printf(m.packageSummary(printFunctions))
}

开发者ID:nmakiya,项目名称:tritium,代码行数:9,代码来源:mixer.go

示例13: Merge

func (m *Mixer) Merge(otherMixer *Mixer) {
    // TODO(SJ) : Make sure there are no name collision in the following unions
    if len(otherMixer.Rewriters) > 0 {

        if len(m.Rewriters) > 0 {
            thisName := null.GetString(m.Name)
            otherName := null.GetString(otherMixer.Name)
            panic(fmt.Sprintf("Duplicate sets of rewriters. Mixer (%v) and mixer (%v) both define rewriters.", thisName, otherName))
        }

        m.Rewriters = otherMixer.Rewriters
    }

    // Merge only exists on (tritium) packager.Package
    m.RootPackage.Merge(otherMixer.Package)

    //  m.RootPackage.Dependencies = append(m.RootPackage.Dependencies, null.GetString(otherMixer.Name) )

}

开发者ID:nmakiya,项目名称:tritium,代码行数:19,代码来源:mixer.go

示例14: FuncStub

func FuncStub(pkg *tp.Package, fun *tp.Function) string {
    name := null.GetString(fun.Name)
    args := ""
    for _, arg := range fun.Args {
        t := pkg.Types[int(null.GetInt32(arg.TypeId))]
        argName := null.GetString(t.Name)
        argName = argName + " %" + null.GetString(arg.Name)
        args = args + ", " + argName
    }
    if len(args) > 1 {
        args = args[2:]
    }
    returnVal := name + "(" + args + ") " + fun.ReturnTypeString(pkg) + " "
    opens := fun.OpensTypeString(pkg)
    if opens != "Base" {
        returnVal = returnVal + opens
    }
    return returnVal
}

开发者ID:nmakiya,项目名称:tritium,代码行数:19,代码来源:doc.go

示例15: findTypeIndex

func (pkg *Package) findTypeIndex(name string) int {
    for index, typeObj := range pkg.Types {
        if name == null.GetString(typeObj.Name) {
            return index
        }
    }

    log.Panic("Bad type load order, type ", name, " unknown")
    return -1
}

开发者ID:nmakiya,项目名称:tritium,代码行数:10,代码来源:resolve.go

示例16: getRawTemplate

func getRawTemplate(segmentName string, mixer *tp.Mixer) (rawTemplate []uint8, err error) {

    for _, segment := range mixer.Rewriters {
        _, thisName := filepath.Split(null.GetString(segment.Path))
        if thisName == segmentName {
            return segment.Data, nil
        }
    }

    return nil, errors.New(fmt.Sprintf("Could not find rewriter: %v", segmentName))
}

开发者ID:nmakiya,项目名称:tritium,代码行数:11,代码来源:generator.go

示例17: CheckForNotMisuse

func (result *CheckResult) CheckForNotMisuse(script *tp.ScriptObject) {
    iterate(script, func(ins *tp.Instruction) {
        if *ins.Type == constants.Instruction_FUNCTION_CALL {
            name := null.GetString(ins.Value)
            if name == "match" || name == "with" {
                if ins.Arguments != nil {
                    for _, arg := range ins.Arguments {
                        if *arg.Type == constants.Instruction_FUNCTION_CALL {
                            if null.GetString(arg.Value) == "not" {
                                result.AddScriptWarning(script, ins, "Possible misuse of not()– remember not is the opposite of with!")
                            }
                        }
                    }
                }

            }
        }

    })
}

开发者ID:nmakiya,项目名称:tritium,代码行数:20,代码来源:checks.go

示例18: Clone

func (fun *Function) Clone() protoface.Function {
    bytes, err := pb.Marshal(fun)

    if err != nil {
        panic("Couldn't clone function" + null.GetString(fun.Name))
    }

    newFun := &Function{}
    pb.Unmarshal(bytes, newFun)

    return newFun
}

开发者ID:nmakiya,项目名称:tritium,代码行数:12,代码来源:function.go

示例19: Process

func Process(pkg *tp.Package) string {
    for tindex, ttype := range pkg.Types {
        ttypeString := null.GetString(ttype.Name)
        println()
        for _, fun := range pkg.Functions {
            if tindex == int(null.GetInt32(fun.ScopeTypeId)) {
                println(ttypeString + "." + FuncStub(pkg, fun))
            }
        }
    }
    return ""
}

开发者ID:nmakiya,项目名称:tritium,代码行数:12,代码来源:doc.go

示例20: CheckXpath

func (result *CheckResult) CheckXpath(script *tp.ScriptObject) {
    iterate(script, func(ins *tp.Instruction) {
        if *ins.Type == constants.Instruction_FUNCTION_CALL {
            name := null.GetString(ins.Value)
            // These all take xpath as the first param
            for _, xpath_func := range xpath_funcs {
                if name == xpath_func {
                    if ins.Arguments != nil {
                        if len(ins.Arguments) > 0 {
                            test_xpath := null.GetString(ins.Arguments[0].Value)
                            err := xpath.Check(test_xpath)
                            if err != nil {
                                result.AddXpathWarning(script, ins, err.Error())
                            }
                        }
                    }
                }
            }
        }
    })
}

开发者ID:nmakiya,项目名称:tritium,代码行数:21,代码来源:xpath.go

最后编辑: goerone  文档更新时间: 2021-08-23 19:14   作者:goerone