首页 > 解决方案 > 程序可执行文件不运行

问题描述

如果我运行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")
}

标签: gofish

解决方案


应该是package main

package main
import "fmt"

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

https://tour.golang.org/welcome


推荐阅读