今天创建了一个GO项目,写了几行代码

package chapter1

import "fmt"

func main() {
    fmt.Println("hello world")
}

运行后抛出如下异常:

runnerw.exe: CreateProcess failed with error 216: 
Process finished with exit code 216

解决方案

经过排查,原来是因为idea在模块包chapter1创建go文件的话,默认导包名称是用了模块名package chapter1 导致了和main函数名称不一致,在GO中,package main表示一个可独立执行的程序,每个 Go 应用程序都包含一个名为main的包,这里的main函数必须对应导入的包名是 package main
GO异常 | runnerw.exe: CreateProcess failed with error 21

只需要把包名改成main即可解决问题

package main


import "fmt"

func main() {
    fmt.Println("hello world")
}

GO异常 | runnerw.exe: CreateProcess failed with error 21

相关文章:

  • 2021-09-15
  • 2022-12-23
  • 2022-12-23
  • 2021-07-10
  • 2021-10-03
  • 2021-06-19
  • 2022-12-23
  • 2021-04-14
猜你喜欢
  • 2021-11-22
  • 2022-02-16
  • 2022-12-23
  • 2021-05-15
  • 2022-12-23
  • 2021-05-21
  • 2021-04-06
相关资源
相似解决方案