Do you think i could take advantage of importer to serialize stdlib, then unserialize it rather than process it every times ?
Are those types linked to some sort of unserializable resource that would prevent that to happen ? On Tuesday, May 16, 2017 at 1:43:44 AM UTC+2, mhh...@gmail.com wrote: > > Hi, > > I wrote this func to load a program, > its faster but it has drawbacks about error managements. > It might hide some messages. > > the first time i ran this function, > without a special typechecker error handler, > I felt overwhelmed by the amount of errors generated. > > in this func s is an import path, > and only that path should be loaded (so far). > The import is very superficial. > > Is there a better/correct way to write a conf > that achieves similar speed goal > but with good error triage ? > > Should i use another api ? > > I m mostly interested into > inspecting the definitions, > create new definitions, > update some definitions in place, > to be able to process the source even if it contains errors, > unless they are critical. > > Thanks > > > // GetFastProgramLoader returns a fast program loader > func GetFastProgramLoader(s string) loader.Config { > var conf loader.Config > conf.ParserMode = parser.ParseComments > conf.TypeChecker.IgnoreFuncBodies = true > conf.TypeChecker.DisableUnusedImportCheck = true > conf.TypeChecker.Error = func(err error) { > if !err.(*types.Error).Soft { > panic(err) > } > if strings.Index(err.Error(), "could not import") == -1 || > strings.Index(err.Error(), "undeclared name:") == -1 { > return > } > log.Println(err) > } > > // this really matters otherise its a pain to generate a partial > program. > conf.AllowErrors = true > originalPkgFinder := (*build.Context).Import > conf.FindPackage = func(ctxt *build.Context, fromDir, importPath > string, mode build.ImportMode) (*build.Package, error) { > if fromDir == s { > return originalPkgFinder(ctxt, fromDir, importPath, mode) > } > return nil, fmt.Errorf("skipped %v %v", fromDir, importPath) > } > return conf > } > > > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.