I'm starting a Golang course and I'm super new to developing, but having issues with packages. Currently on a lecture about Variables when I go to run the code it gives me
package variables is not in std C:\Program Files\Go\src\variables
I think it might be an environment variables' issue as these keep coming up but I'm very unsure, I've tried looking at the paths in my environment variables and I don't seem to be finding the issue. Could anyone take a look at my screenshots and assist me with the issue? Thank you
environment variables
code im running in VS Code
I've ensured that the mod file is within the lectures project, I've checked my system environment variables. When running code in git I've made sure I'm in the working directory as to where the variable lecture is
Try changing the name of the application file to
main.goIf that fixes it, then the problem is that you need initialize a module named "variables".
In the terminal run
Then change the app file name back to variables.go
Until you get to more complicated apps you don't necessarily need to init a modules for your code. But then the app file must be main.go
Read more about code organization here.