Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

GO no go.mod file exists in directory

I’m starting with GO, and I want to create a virtualenv like in Python (to store import modules at the project directory itself), I read in GO’s doc https://go.dev/doc/tutorial/workspaces and understand that GO’s Create the workspace is what i’m doing need. But when I do, it doesn’t work. Like in the attached image, after "go mod init …/hello_go" complete, then "go work init ./hello_go" and something wrong.

I don’t understand what is the problem?

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The problem is that the go.work file is supposed to be at the root of your project and point to subdirectories containing a go.mod file.

The error is telling you that there is no directory ./hello_go containing a go.mod file. This is correct because you have initialized your module also at the root level.

If you have only a single module, you don’t need to create a workspace. You can create your module at root level like you did, and then use go mod to manage your dependencies for that particular module.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading