Skip to content
This repository has been archived by the owner on Sep 1, 2018. It is now read-only.

Commit

Permalink
Decouple custom cache struct from loader.Config
Browse files Browse the repository at this point in the history
Will help with impementing lint.Checker.
  • Loading branch information
mvdan committed Mar 21, 2017
1 parent f8e68b7 commit a510bc3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
7 changes: 0 additions & 7 deletions cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ type typeSet struct {
funcs map[string]string
}

func newCache(paths []string) *cache {
c := &cache{grabbed: make(map[string]pkgCache)}
c.AllowErrors = true
c.TypeChecker.Error = func(e error) {}
return c
}

func (c *cache) isFuncType(t string) bool {
if stdFuncs[t] {
return true
Expand Down
9 changes: 6 additions & 3 deletions check.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,17 @@ type visitor struct {
// any.
func CheckArgs(args []string, onWarns func(string, []Warn)) error {
paths := gotool.ImportPaths(args)
c := newCache(paths)
rest, err := c.FromArgs(paths, false)
conf := loader.Config{}
conf.AllowErrors = true
conf.TypeChecker.Error = func(e error) {}
rest, err := conf.FromArgs(paths, false)
if err != nil {
return err
}
if len(rest) > 0 {
return fmt.Errorf("unwanted extra args: %v", rest)
}
lprog, err := c.Load()
lprog, err := conf.Load()
if err != nil {
return err
}
Expand All @@ -139,6 +141,7 @@ func CheckArgs(args []string, onWarns func(string, []Warn)) error {
if err != nil {
return err
}
c := &cache{grabbed: make(map[string]pkgCache)}
v := &visitor{
cache: c,
fset: lprog.Fset,
Expand Down

0 comments on commit a510bc3

Please sign in to comment.