gaojie@Joy$ cat main.go
package main func Add(i int, j int) int{ return i+j }
gaojie@Joy$ cat main_test.go
package main import "testing" //要測試方法前增長"Test"開頭 func TestAdd(t *testing.T){ if (Add(2, 4) == 6){ t.Log("ok pass") }else{ t.Error("error") } }