skipmaple
skipmaple

Reputation: 81

How can I fix go get: disabled by -mod=vendor

I used export GO111MODULE=on

when i type go get -u github.com/swaggo/swag/cmd/swag

I got go get: disabled by -mod=vendor

so i can't use the go get any more, anyone who can help me?

and my go env like this:

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/maple/Library/Caches/go-build"
GOEXE=""
GOFLAGS=" -mod=vendor"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/maple/go"
GOPROXY="https://goproxy.io"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/b0/gjtsl1sn61977y7xldkg5f540000gn/T/go-build663727012=/tmp/go-build -gno-record-gcc-switches -fno-common"

i found there has a GOFLAGS=" -mod=vendor", how can i change it?

Upvotes: 7

Views: 9042

Answers (2)

Sanil
Sanil

Reputation: 374

As per Golang documentation, this setting tells go to not automatically update go.mod if an imported module is not found. To disable the read-only mode, you can run

go env -w GOFLAGS=''

Upvotes: 2

dotmnd
dotmnd

Reputation: 81

Based on my personal setup, until this gets fixed/cleaned up upstream, you can simply unset this flag in your variable, i.e:

$ export GOFLAGS=""

This because you don't have any other flags but -mod currently set.

Upvotes: 8

Related Questions