You’ve most likely simply tried to initialise a brand new Go module, and obtained the next error:
go mod init: modules disabled by GO111MODULE=off; see 'go assist modules'
This often occurs after working a command like:
go mod init github.com/<person>/<repo>
From Go model 1.11, the way in which to cope with modules was revamped.
Beforehand, it was required that you simply place all of your Go code below a $GOPATH.
Which many Go builders didn’t very like, because it appeared chaotic at greatest.
Additionally, having a package deal administration/module administration resolution is a lot extra productive, and manageable.
You may at all times simply go and alter the
on as an setting variable and also you’d be good to go!
This might lead to a profitable module being created after attempting the earlier command that resulted within the error within the first place:
go: creating new go.mod: module github.com/<person>/<repo>
Should you’re on Home windows, merely substitute
For a extra direct method of attaining the identical as Answer 1 above, use Go on to replace the setting variable:
go env -w GO111MODULE=on
It’s fairly potential that you’ve a
go.mod file below your
You must take away this file.
Keep in mind that since you’re utilizing Go 1.11 or newer, you need to use the
go get command outdoors of $GOPATH, so it’s now not required.