当前位置:网站首页>Golang Hello installation environment exception [resolved]

Golang Hello installation environment exception [resolved]

2022-06-27 04:20:00 JavaPub-rodert

Abnormal information

Initial installation go Environmental Science -hello

go: go.mod file not found in current directory or any parent directory; see 'go help modules'

 Insert picture description here


Cause analysis :

go The problem of environment configuration of . And golang Package management for .


Solution :

If you are Windows System , Shortcut key “Win+R”, Input cmd, Open the terminal . Input :

go env -w GO111MODULE=auto

explain :

GO111MODULE yes Go 1.11 The new version of module management mode introduced .

GO111MODULE Environment variables are used to turn on or off Go Modules in the language support , It has off、on、auto Three options , The default is auto.

  1. GO111MODULE=off

    No module support ,go From $GOPATH The folder and vendor Find dependencies in directory .

  2. GO111MODULE=on

    Module support ,go Ignore $GOPATH Folder , Based on go.mod Download dependency .

  3. GO111MODULE=auto

    stay $GOPATH/src Outer layer and root directory has go.mod When you file , Enable module support ; No, no module support .

原网站

版权声明
本文为[JavaPub-rodert]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/178/202206270419264425.html