0

I have updated my go version from go1.12.4 to go1.13.4. I have created a project and initialized it with go mod init myproject creating a go.mod file with the information:

module myproject

go 1.13

When I try to download a dependency

 go get github.com/kelseyhightower/envconfig

It returns the following message:

go: flag needs an argument: -mod (from $GOFLAGS)
usage: go get [-d] [-t] [-u] [-v] [-insecure] [build flags] [packages]
Run 'go help get' for details.

I have reviewed the doc from golang modules wiki and from its github issues but couldn't find any solution.

I have downgraded to go1.12.13 version, but I still have the same problem.

My go env variables are:

GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOENV="/home/usser/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/user/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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-build555598313=/tmp/go-build -gno-record-gcc-switches"

Thank you so much

Víctor M
  • 307
  • 4
  • 16

1 Answers1

1

enter image description here

I think the problem is with you IDE: Goland

Use go env in the terminal

Your will see a env value called GOFLAGS, that is the problem

Just unset the env value by using unset GOFLAGS

JWang
  • 181
  • 6
  • I will try it and tell you. Thank you for the reply – Víctor M Nov 11 '19 at 15:15
  • You should enable modules support in the IDE, Settings/Preferences | Go | Go Modules (vgo) for Go Modules to work. – dlsniper Nov 11 '19 at 19:02
  • It is enabled. I have opened a ticket on jetbrains web page because the previous EAP version worked great – Víctor M Nov 12 '19 at 21:03
  • Yes, the EAP version is unstable – JWang Nov 13 '19 at 04:10
  • 1
    I have received their response from the ticket I have opened: "Thank you for reporting the problem. This is a known issue and it has already been fixed. The fix will be included in the next EAP version." – Víctor M Nov 13 '19 at 13:27