Tag Archives: CreateProcess failed with error

GO Exception Runnerw.exe: CreateProcess failed with error 21

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")
}