本文整理匯總了Golang中golang.org/x/tools/go/loader.Config.Build方法的典型用法代碼示例。如果您正苦於以下問題:Golang Config.Build方法的具體用法?Golang Config.Build怎麽用?Golang Config.Build使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類golang.org/x/tools/go/loader.Config
的用法示例。
在下文中一共展示了Config.Build方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: allowErrors
// allowErrors causes type errors to be silently ignored.
// (Not suitable if SSA construction follows.)
func allowErrors(lconf *loader.Config) {
ctxt := *lconf.Build // copy
ctxt.CgoEnabled = false
lconf.Build = &ctxt
lconf.AllowErrors = true
// AllErrors makes the parser always return an AST instead of
// bailing out after 10 errors and returning an empty ast.File.
lconf.ParserMode = parser.AllErrors
lconf.TypeChecker.Error = func(err error) {}
}
示例2: petstoreProgram
func petstoreProgram() *loader.Program {
var ldr loader.Config
ldr.ParserMode = goparser.ParseComments
ldr.Build = &gobuild.Default
ldr.ImportWithTests("github.com/go-swagger/go-swagger/fixtures/goparsing/petstore")
ldr.ImportWithTests("github.com/go-swagger/go-swagger/fixtures/goparsing/petstore/models")
ldr.ImportWithTests("github.com/go-swagger/go-swagger/fixtures/goparsing/petstore/rest/handlers")
prog, err := ldr.Load()
if err != nil {
log.Fatal(err)
}
return prog
}
示例3: classifierProgram
func classifierProgram() *loader.Program {
var ldr loader.Config
ldr.ParserMode = goparser.ParseComments
ldr.Build = &gobuild.Default
ldr.ImportWithTests("github.com/go-swagger/go-swagger/fixtures/goparsing/classification")
ldr.ImportWithTests("github.com/go-swagger/go-swagger/fixtures/goparsing/classification/models")
ldr.ImportWithTests("github.com/go-swagger/go-swagger/fixtures/goparsing/classification/operations")
prog, err := ldr.Load()
if err != nil {
log.Fatal(err)
}
return prog
}