golang/go

x/tools/cmd/goimports: do not prefix packages from GOROOT if it is inside a module

Open

#31.206 aperta il 2 apr 2019

Vedi su GitHub
 (4 commenti) (0 reazioni) (0 assegnatari)Go (19.008 fork)batch import
NeedsFixToolshelp wanted

Metriche repository

Star
 (133.883 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

What version of Go are you using (go version)?

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

What did you do?

I have a GOROOT inside a module (a per-repository Go installation for a hermetic build).

I run goimports, it tries to resolve a package (say, reflect), it loads packages from GOROOT, and they end up being prefixed with a path inside the current module.

What did you expect to see?

package mypkg

import "reflect"

type x reflect.Type

What did you see instead?

package mypkg

import "my.module/_deps/go-1.12beta2/src/reflect"

type x reflect.Type

How to fix

[Patch redacted by @bcmills. Please send a PR or CL so that we can verify CLA compliance.]

Guida contributor