如何编译Go程序?

18 go

编译:

0 known bugs; 0 unexpected bugs

并输入"hello world":

package main

import "fmt"

func main() {
  fmt.Printf("Hello, ??\n")
}
Run Code Online (Sandbox Code Playgroud)

然后我试着编译它,但它不会去:

$ 8c gotest2
gotest2:1 not a function
gotest2:1 syntax error, last name: main

这是在Pentium上的Ubuntu Linux上进行的.安装并通过测试.那我哪里出错了?谁能告诉我从哪里开始?

我也试过这个程序:

package main

import fmt "fmt"  // Package implementing formatted I/O.


func main() {
    fmt.Printf("Hello, world; or ???????? ?????; or ????? ??\n");
}
Run Code Online (Sandbox Code Playgroud)

但这也没有去(必须停止制作双关语):

$ 8c gotest3.go
gotest3.go:1 not a function
gotest3.go:1 syntax error, last name: main

小智 38

对于Go 1.0+,现在正确的构建命令: go build


Sco*_*les 12

你正在使用8c,这是c编译器.8g将编译go,而8l将链接.