Go语句不需要额外的标记,就像python一样。 go的运行方式:go的运行方式xx.gotest: go testxxx.go-v添加新包:go get xxx第一个go程序包main import " fmt " funcmain(){ fmt . println(" Hello,world!")}函数func function _ name([参数列表]) [return _ types] {//body}第一个测试函数引入到包“Testing”中,函数必须命名为TestXXX,参数必须包含测试类型的指针。 下面是一个简单的例子,TestF1测试F1。 package test import“testing”func f1(a int,b int)int { return a+b } func test f1(t * testing。T){ if f1(1,2)!= 3{ t.Error(`f1错误!`)}}测试结果= = =运行testf1-pass: testf1 (0.00s) pass进程结束,退出代码为0