- 
                Notifications
    
You must be signed in to change notification settings  - Fork 18.4k
 
Open
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.modules
Milestone
Description
What version of Go are you using (go version)?
$ go version go version go1.12.4
goimports from from https://github.com/golang/tools, commit d1a3278ee74994e9aa609e9e711c616bba677d5d
Does this issue reproduce with the latest release?
Yes, reproducible with go 1.12.5
What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/fho/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/fho/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/testproject/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build188015067=/tmp/go-build -gno-record-gcc-switches"
What did you do?
- Create a new golang project using go.mod.
The project has a amain.gofile that imports the external dependencygithub.com/lib/pq.
The external modules are downloaded intovendor/viago mod vendor. 
mkdir -p /tmp/testproject
cd /tmp/testproject
go mod init "testproject"
echo 'package main
import (
	"fmt"
	"github.com/lib/pq"
)
func main() {
	var test pq.StringArray
	fmt.Println(test)
}' > main.go
go mod vendor
- Remove the 
"github.com/lib/pq"import from main.go: 
sed -i '/"github.com\/lib\/pq"/D' main.go
- Remove 
$GOPATH/pkg, run goimports withGOFLAGS=-mod=vendor: 
sudo rm -rf $(go env GOPATH)/pkg
GOFLAGS="-mod=vendor" goimports -d main.go
What did you expect to see?
goimports detects the missing github.com/lib/pq import and shows it in the diff.
What did you see instead?
goimports  does not find the missing github.com/lib/pg import and prints no diff.
nocive
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.modules