go version
)?$ go version go version go1.12.5 linux/amd64
Yes.
go env
)?go env
Output
$ go env
GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/usr/local/google/home/trillian/go"
GOROOT="/usr/lib/google-golang"
GOTOOLDIR="/usr/lib/google-golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build732986152=/tmp/go-build -gno-record-gcc-switches"
Updated VS Code settings per instructions:
https://github.com/Microsoft/vscode-go/wiki/Go-modules-support-in-Visual-Studio-Code
https://github.com/golang/go/wiki/gopls#vscode
{
"go.useLanguageServer": true,
"[go]": {
"editor.snippetSuggestions": "none",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"gopls": {
"usePlaceholders": true // add parameter placeholders when completing a function
},
"files.eol": "\n", // formatting only supports LF line endings
}
go.mod:
module github.com/DazWilkin/basic-personality
go 1.12
require (
github.com/gogo/protobuf v1.2.1
github.com/google/certificate-transparency-go v1.0.21 // indirect
github.com/google/trillian v1.2.1
github.com/grpc-ecosystem/grpc-gateway v1.9.2 // indirect
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
golang.org/x/net v0.0.0-20190628185345-da137c7871d7 // indirect
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/tools v0.0.0-20190702152245-7e72c71c505f // indirect
golang.org/x/tools/gopls v0.1.2-0.20190702152245-7e72c71c505f // indirect
google.golang.org/grpc v1.21.1
)
GOPATH=$PWD/go
cd go/src/github.com/DazWilkin/basic-personality
GO111MODULE=on go get ./...
code --new-window .
And both the non-standard library imports error:
If, instead, I import old-school:
GO111MODULE=off go get ./...
It works.
I suspect I'm missing something either with this solution or with Go Modules (or both) but I'm expecting to be able to use the Go Modules (GO111MODULE=on) approach with this solution.
Is it because I'm still working under ${GOPATH}
and have it set?
Perhaps related to #32762 ?
You will need to set
"go.toolsEnvVars": {
"GO111MODULE": "on",
},
to work with modules in VSCode.
Yes, that works.
I changed the setting, deleted the ${GOPATH}/src/github.com/google/trillian
, reloaded and no more import error.
Thank you!!
Most helpful comment
You will need to set
to work with modules in VSCode.