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

2

7

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?

Nicholle answered 22/10, 2019 at 3:5 Comment(2)
Welcome to SO! When you place a question try to add a minimum content: input sample, expected output sample, what did you try, research and where are you stacked.. What did you try? Any research?Responsum
GOFLAGS= go get -u github.com/swaggo/swag/cmd/swagTitleholder
S
8

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.

Swinge answered 22/10, 2019 at 8:6 Comment(0)
M
2

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=''
Metzger answered 22/12, 2020 at 18:2 Comment(1)
export GOFLAGS="" this did not work but go env -w GOFLAGS='' this workedUnbolt

© 2022 - 2024 — McMap. All rights reserved.