go - 如何编译 Go 程序?

标签 go

我得到Go编译:

0 known bugs; 0 unexpected bugs

and typed in the "hello world":

package main

import "fmt"

func main() {
  fmt.Printf("Hello, 世界\n")
}

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

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

This is going on on Ubuntu Linux on Pentium. Go installed and passed its tests. So where did I go wrong? Can someone tell me where to go from here?

I also tried this program:

package main

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


func main() {
    fmt.Printf("Hello, world; or Καλημέρα κόσμε; or こんにちは 世界\n");
}

但这也是不行的(必须停止双关语):

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

最佳答案

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

关于go - 如何编译 Go 程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1714584/

相关文章:

go - Couchbase查询错误5000(打开C:\Couchbase\Server\var\lib\couchbase\tmp\scan-results5960831968761:系统找不到指定的路径

golang 包导入失败

Go:接口(interface)作为返回值

go - 如何获取 io.reader 对象的大小

xml - 用Go解析xml,有多个项目

dictionary - 根据键数组和值构建任意深度的嵌套 map

mysql - 如何在使用 cgo 构建时调试/转储 Go 变量?

go - 在 cli 中使用进度条

go - 我们在使用google protocol buffer时,是否可以修改生成的pb.go文件?

testing - 如何在 Golang 中获得 100% 的代码覆盖率?