mirror of
https://github.com/golang/go.git
synced 2025-05-05 07:33:00 +00:00
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>
This commit is contained in:
parent
eda2c2f1ae
commit
26647e34d3
@ -35,6 +35,9 @@ var LocalPrefix string
|
|||||||
// so it is important that filename be accurate.
|
// 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.
|
// 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) {
|
func Process(filename string, src []byte, opt *Options) ([]byte, error) {
|
||||||
|
if opt == nil {
|
||||||
|
opt = &Options{Comments: true, TabIndent: true, TabWidth: 8}
|
||||||
|
}
|
||||||
intopt := &intimp.Options{
|
intopt := &intimp.Options{
|
||||||
Env: &intimp.ProcessEnv{
|
Env: &intimp.ProcessEnv{
|
||||||
GOPATH: build.Default.GOPATH,
|
GOPATH: build.Default.GOPATH,
|
||||||
|
@ -42,9 +42,6 @@ type Options struct {
|
|||||||
|
|
||||||
// Process implements golang.org/x/tools/imports.Process with explicit context in env.
|
// Process implements golang.org/x/tools/imports.Process with explicit context in env.
|
||||||
func Process(filename string, src []byte, opt *Options) ([]byte, error) {
|
func Process(filename string, src []byte, opt *Options) ([]byte, error) {
|
||||||
if opt == nil {
|
|
||||||
opt = &Options{Comments: true, TabIndent: true, TabWidth: 8}
|
|
||||||
}
|
|
||||||
if src == nil {
|
if src == nil {
|
||||||
b, err := ioutil.ReadFile(filename)
|
b, err := ioutil.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user