// 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) {} }
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 }
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 }