background
Today, I created a go project and wrote a few lines of code
package chapter1
import "fmt"
func main() {
fmt.Println("hello world")
}
After running, the following exception is thrown:
runnerw.exe: CreateProcess failed with error 216:
Process finished with exit code 216
Solution
After troubleshooting, it turns out that if idea creates a go file in module package Chapter 1
, the default package name is module name package Chapter 1
, which leads to inconsistency with the name of main function. In go, package main
represents a program that can be executed independently, and each go function has its own name All applications contain a package named main
. The main function here must correspond to the imported package name package main
Just change the package name to main
to solve the problem
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
Read More:
- [Solved] .\main.go:3:6: missing function body .\main.go:4:1: syntax error: unexpected semicolon or newline be
- [Solved] Golang Error: main.go:5:2: package go_code/chapter10/factory/model is not in GOROOT
- Go declares that the local variable does not use command line arguments. Main. Go: 4:6: a declared but not used
- [Solved] Error running ‘go build myfir_go_project‘: Cannot run program
- [Solved] Error: error getting chaincode bytes: ‘go list‘ failed with: cannot find module providing package
- Docker run Error: container_linux.go:235: starting container process caused “process_linux.go:258: appl
- [Solved] Fabric_sdk_go:QueryBlockConfig failed: QueryBlockConfig failed: target(s) required
- [Solved] docker Error response from daemon OCI runtime create failed container_linux.go380
- [Solved] UE4 Android Package Error: cmd.exe failed with args
- [Solved] VScode Error: build constraints exclude all Go files in syscall\js
- [Solved] Go language gob serialization pointer cannot be addressed Error
- [Go] Testing when solving go test: warning: no tests to run
- QT Error: ‘C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe‘ failed
- [Solved] go cobra Error: required flag(s) “pkg-name” not set
- [Solved] scala Error: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exe
- [Solved] Android Studio Error: CreateProcess error = 206 file name or extension is too long
- [Solved] Go Get Download Dependency Error: is not using a known version control system
- How to Solve error: command ‘C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc.exe‘ failed
- [GO] The entry file under the main package in golang calls other go file functions and appears undefined
- How to Solve Docker Error: elasticsearch exception: type=cluster_block_exception, reason=blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];