diff options
Diffstat (limited to 'vendor/golang.org/x/tools/imports/imports.go')
-rw-r--r-- | vendor/golang.org/x/tools/imports/imports.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/vendor/golang.org/x/tools/imports/imports.go b/vendor/golang.org/x/tools/imports/imports.go index a4cbf5c7..07101cb8 100644 --- a/vendor/golang.org/x/tools/imports/imports.go +++ b/vendor/golang.org/x/tools/imports/imports.go @@ -13,6 +13,7 @@ import ( "bytes" "fmt" "go/ast" + "go/build" "go/format" "go/parser" "go/printer" @@ -45,6 +46,11 @@ type Options struct { // so it is important that filename be accurate. // To process data ``as if'' it were in filename, pass the data as a non-nil src. func Process(filename string, src []byte, opt *Options) ([]byte, error) { + env := &fixEnv{GOPATH: build.Default.GOPATH, GOROOT: build.Default.GOROOT} + return process(filename, src, opt, env) +} + +func process(filename string, src []byte, opt *Options, env *fixEnv) ([]byte, error) { if opt == nil { opt = &Options{Comments: true, TabIndent: true, TabWidth: 8} } @@ -63,8 +69,7 @@ func Process(filename string, src []byte, opt *Options) ([]byte, error) { } if !opt.FormatOnly { - _, err = fixImports(fileSet, file, filename) - if err != nil { + if err := fixImports(fileSet, file, filename, env); err != nil { return nil, err } } |