Home > Article > Backend Development > After building correctly Main.go will not run
In this article, php editor Xinyi will introduce how to correctly build the Main.go file to avoid problems that cannot be run. Main.go is the main entry file of the Go language program. The built Main.go file is the key to running our program. However, if you don't pay attention to some details, it may cause the program to not run properly. Therefore, this article will explain in detail the steps and precautions for correctly building Main.go to help readers avoid running problems and ensure that the program runs smoothly.
I started to learn go and made a crm application, but found that after building main, it could not run.
This is the error shown in the terminal:
PS crm-go-fiber> go build .\main.go PS crm-go-fiber> go run .\main.exe main module (github.com/Lo0mi3x/crm-go-fiber) does not contain package github.com/Lo0mi3x/crm-go-fiber/main.exe
I'm new to programming, github, etc., but I did my commits and pushes and everything was correct. Even cloned the code from my repository and tried again but nothing changed.
Your program is not executed correctly.
go build .\main.go
This command compiles and builds main.go
. However, you generally should not pass filenames to go build
. A better way is go build
. But that's not your real problem...
go run .\main.exe
This command attempts to build and run a package named main.exe
located in the current directory. The error message you see:
main module (github.com/lo0mi3x/crm-go-fiber) does not contain package github.com/lo0mi3x/crm-go-fiber/main.exe
tells you that the package named main.exe
cannot be found in the current package.
If you want to execute the program compiled in the first command, just execute it as usual:
.\main.exe
The above is the detailed content of After building correctly Main.go will not run. For more information, please follow other related articles on the PHP Chinese website!