From 26647e34d3c04fd3eaef6fb824493b00af7b1b26 Mon Sep 17 00:00:00 2001 From: Heschi Kreinick Date: Mon, 20 May 2019 18:00:48 -0400 Subject: [PATCH] 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 Reviewed-by: Ian Cottrell TryBot-Result: Gobot Gobot --- imports/forward.go | 3 +++ internal/imports/imports.go | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imports/forward.go b/imports/forward.go index bb661d59..eef25969 100644 --- a/imports/forward.go +++ b/imports/forward.go @@ -35,6 +35,9 @@ var LocalPrefix string // 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 8b63908c..62533376 100644 --- a/internal/imports/imports.go +++ b/internal/imports/imports.go @@ -42,9 +42,6 @@ type Options struct { // 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 {