g ls-remote stable
g use
g ls
Learn More →
Learn More →
calculate/add.go
package calculate
func Add(a, b int) int {
return a + b
}
calculate/add_test.go
package calculate
import "testing"
func TestAdd(t *testing.T) {
if Add(1, 2) != 3 {
t.Errorf("1+2=%d wrong number", Add(1, 2))
}
}
main.go
package main
import (
"0216/calculate"
"fmt"
)
func main() {
fmt.Println(calculate.Add(1, 2))
}
go test -v ./calculate
Learn More →
go test -v ./calculate -cover
Learn More →
go test -coverprofile=coverage.out .
Learn More →
go tool cover -html=coverage.out
Learn More →
go test -v ./calculate -bench="."
Learn More →
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up