Go开始

Go 

程序入口

1、必须是 main 包:package main

2、必须是 main 方法:func main()

3、文件名不一定是 main.go

退出返回值

与其他语言的差异

package main

import (
    "fmt"
    "os"
)

func main() {
    fmt.Println(os.Args)
    fmt.Println(len(os.Args))
    if len(os.Args) > 1 {
        fmt.Println("hello world:" + os.Args[1])
    }
    os.Exit(0)
}

编写测试程序

1、源码文件以_test结尾:xxx_test.go

2、测试方法名以Test开头:func Testxxx(t *testing.T){...}

变量赋值

与其他语言的差异