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 GO111MODULE=auto in GOPATH/src; ignoring ../go.mod; see 'go help modules' package golang.org/x/lint/golint: unrecognized import path "golang.org/x/lint/golint" (https fetch: Get https://golang.org/x/lint/golint?go-get=1: dial tcp 216.58.200.192:443: i/o timeout)
I then try to install golang/tools, also failed...
package golang.org/x/tools: unrecognized import path "golang.org/x/tools" (https fetch: Get https://golang.org/x/tools?go-get=1: dial tcp 216.58.200.192:443: i/o timeout)
As mentioned above, Go runtime still does use $GOPATH as a download directory of Go packages. To make the Google's saying correct, Go module does not entirely replace GOPATH , but replaces GOPATH for version control and package distribution.
GO111MODULE is an environment variable that can be set when using go for changing how Go imports packages. One of the first pain-points is that depending on the Go version, its semantics change.
Since 1.12 version Go modules is enabled by default and the GOPATH will be deprecated in 1.13 version. For those who are getting started with Go 1.12, the installation and set up goes will be as follows.
Make sure Go Modules integration is enabled in settings (Preferences / Settings | Go | Go Modules), and GOPATH indexing is disabled (Preferences / Settings | Go | GOPATH | Index entire GOPATH). As soon as I did this, the red imports went away and everything worked. Show activity on this post.
Basically, enable go modules in GoLand via: Make sure Go Modules integration is enabled in settings (Preferences / Settings | Go | Go Modules), and GOPATH indexing is disabled (Preferences / Settings | Go | GOPATH | Index entire GOPATH). As soon as I did this, the red imports went away and everything worked.
Fix up your go.mod: the generated file contains module "outsidegopath", but we want something like module github.com/stevetarver/outsidegopath. This is a bit wonky - GoLand will try to rewrite go.mod and remove parts of the path. Repeat a couple times and it will stop trying.
Create your main.go file referencing a package that does not exist in your $GOPATH. Add that package to your imports. Using go get the GoLand way via vgo as described in the gif here: Click on the import package. Click on the red inspection bulb. Click on "Sync packages of ...". Open the embedded terminal. go get your import.
I ran this command
export GO111MODULE="on"
and that worked for me...
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With