Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

go

go-modules

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?

like image 960
skipmaple Avatar asked Oct 22 '19 03:10

skipmaple


Video Answer


2 Answers

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.

like image 189
dotmnd Avatar answered Sep 21 '22 19:09

dotmnd


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=''
like image 41
Sanil Avatar answered Sep 21 '22 19:09

Sanil