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.
Question content
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.
Solution
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The problem of using RedisStream to implement message queues in Go language is using Go language and Redis...

Queue threading problem in Go crawler Colly explores the problem of using the Colly crawler library in Go language, developers often encounter problems with threads and request queues. �...

What should I do if the custom structure labels in GoLand are not displayed? When using GoLand for Go language development, many developers will encounter custom structure tags...

The difference between string printing in Go language: The difference in the effect of using Println and string() functions is in Go...

The library used for floating-point number operation in Go language introduces how to ensure the accuracy is...

Two ways to define structures in Go language: the difference between var and type keywords. When defining structures, Go language often sees two different ways of writing: First...

Which libraries in Go are developed by large companies or well-known open source projects? When programming in Go, developers often encounter some common needs, ...

When using sql.Open, why doesn’t the DSN report an error? In Go language, sql.Open...
