How to fix “go get: warning: modules disabled by GO111MODULE=auto in GOPATH/src”

后端 未结 3 926
情话喂你
情话喂你 2021-02-18 16:37

I\'m trying to install golint with the command: go get -u golang.org/x/lint/golint. And I think I got two problems:

go get: warning: 
    modules disabled by GO         


        
相关标签:
3条回答
  • 2021-02-18 17:16

    Also got this error when trying to work with vgo

    Removing GOROOT (you don't need to explicitly set GOROOT, Modern versions of Go can figure it out on their own based on the location of the go binary that you run), updating my GOPATH and export GO111MODULE="on" resolved the issue.

    GOPATH see in here

    GOPATH may be set to a colon-separated list of paths inside which Go code, package objects, and executables may be found.

    Set a GOPATH to use goinstall to build and install your own code and external libraries outside of the Go tree (and to avoid writing Makefiles).

    0 讨论(0)
  • 2021-02-18 17:19

    I ran this command

    export GO111MODULE="on" 
    

    and that worked for me...

    0 讨论(0)
  • 2021-02-18 17:24

    It looks like you have a go.mod file inside $GOPATH/ (under $GOPATH/go.mod). You should remove that. Also, since you are using Go 1.11 or newer, you can run the go get command from well outside of GOPATH/any directory containing a go.mod file either directly or in a parent directory, and then the command should work.

    0 讨论(0)
提交回复
热议问题