go-开启go module

1
2
λ go mod init
go: modules disabled inside GOPATH/src by GO111MODULE=auto; see 'go help modules'

开启go module:

1
2
set GO111MODULE=on    //windows
export GO111MODULE=on //linux

上面的命令开启go module是临时开启

永久开启

1
2
3
4
配置powershell
# Enable the go modules feature
$env:GO111MODULE="on" //windows
#echo 'export GO111MODULE=on' >> /etc/profile //linux