go - 程序可执行文件不运行
问题描述
如果我运行go build -o bin/test ./scripts/test.go
,我会得到一个可执行文件,但是当我尝试运行它时,我会得到
Failed to execute process './bin/test'. Reason:
exec: Exec format error
The file './bin/test' is marked as an executable but could not be run by the operating system.
脚本/test.go
package scripts
import (
"fmt"
)
func main() {
fmt.Println("hello")
}
解决方案
应该是package main
:
package main
import "fmt"
func main() {
fmt.Println("hello")
}
推荐阅读
- c# - 控制台与 WebAPI 中共享类库的 MediatR 设置
- git - 如何向 .gitignore 添加内容?
- android - Flutter Launcher 图标没有改变?
- javascript - 它没有在控制台屏幕上显示任何输出。可能是什么问题
- python - Django DateTimeField 说“你比服务器时间提前 5.5 小时。”
- javascript - 从 javascript 客户端发送从 xmpp 协议收到的通知确认
- javascript - 在 REACT 兄弟组件之间传递数据
- android - 无法实例化 appComponentFactory
- html - 带图像的按钮
- bash - 如何在 Windows 中从 gitbash 运行 jq?