imports: allow nil Options in Process
Forgot this case in CL 175437.
Change-Id: I9825cf010611fed9f47b1a87fc793bf3a5a36f68
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178257
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/imports/forward.go b/imports/forward.go
index bb661d5..eef2596 100644
--- a/imports/forward.go
+++ b/imports/forward.go
@@ -35,6 +35,9 @@
// 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) {
+ if opt == nil {
+ opt = &Options{Comments: true, TabIndent: true, TabWidth: 8}
+ }
intopt := &intimp.Options{
Env: &intimp.ProcessEnv{
GOPATH: build.Default.GOPATH,
diff --git a/internal/imports/imports.go b/internal/imports/imports.go
index 8b63908..6253337 100644
--- a/internal/imports/imports.go
+++ b/internal/imports/imports.go
@@ -42,9 +42,6 @@
// Process implements golang.org/x/tools/imports.Process with explicit context in env.
func Process(filename string, src []byte, opt *Options) ([]byte, error) {
- if opt == nil {
- opt = &Options{Comments: true, TabIndent: true, TabWidth: 8}
- }
if src == nil {
b, err := ioutil.ReadFile(filename)
if err != nil {