I was born in Java. Recently I became interested in go language, so I will learn it with go in the future.
After the go environment is installed and configured, the vscode development tool is installed, and the first go program is written. It’s very simple, just a simple output statement, but it does
Go run: cannot run non main package. The code is as follows:
package test
import "fmt"
func main() {
fmt.Println("cainiaobulan testing go")
}
The error message of go is very straightforward. The main method can only be placed in package main. Go run is to execute the command and a main must be used to call it. Install can be directly compiled into a package file or an EXE (if there is a main function)
Change the code and run OK
package main
import "fmt"
func main() {
fmt.Println("cainiaobulan testing go")
}
Just take this mistake as the first step for me to learn go. In the future, I can cross the pit step by step. I hope that children’s shoes with the same interest can learn together and carry forward go. At the same time, I also want to seek guidance from the boss. I am ready to develop in the direction of go web.
Read More:
- Go compiles the EXE executable to remove the CMD window at run time
- Docker run failed with the following error in logs, standard_ init_ linux.go:211 : exec user process caused “exec format error“
- [Solved] #command-line-arguments .\main.go:5:4: no new variables on left side of :=
- After installing CodeBlocks, run the prompt: tried to run compiler executable ‘C: / / MinGW / bin / mingw32- gcc.exe ‘, but failed!
- Go get github.com/kotakanbe/go -Problems encountered in CVE dictionary Download
- Android AS Run main Method Error [How to Solve]
- Eclipse run main method error: a JNI error has occurred, please check your installation and try again
- [go] solve the fatal error of go: concurrent map writes map non concurrent security
- Error in go running: cannot find package “
- NPM run build failed to package err! Missing script: build
- Install and run phantomjs on MAC
- Python server run code ModuleNotFoundError Error [How to Solve]
- NPM run build error solution
- Error report of GoLand project after go reloading Error:cannot find The solution of package error
- Run Red Alert and other old games under Win10…
- Go test print no output
- Error 2738. Could not access VBScript run time for custom action.
- run.bat Operation flashback
- Run time error “430”
- Import Maven project error, unable to run