How to use the moudle function of golang version 1.11?

I turned on the moudle function in the environment variable


Jan.15,2022

Don't change it yourself. It is automatically identified. When your project directory has go.mod, it will automatically enable
refer to this article: https://www.jianshu.com/p/c57.


Amway justforfunc https://www.youtube.com/chann.-sharp42-sharp43 period is all about the use of go modules.

personal experience: go module is much easier to manage than the previously used gvt ~

you have set up GO111MODULES=on, here, which means you need to have a go.mod file in the root directory of your project, and that's what your error report means. As for what you said about go mod init, it doesn't work? What is the wrong report?

my guess is that you are outside gopath and your project is not managed by VCS. If so, the solution is:

// module
go mod init MODULE_NAME

you can generate a go.mod file

Menu