func TestMyFunction(t *testing.T) { result := MyFunction() if result != expected { t.Errorf("Expected %v but got %v", expected, result) } }
func TestMyOtherFunction(t *testing.T) { if err := MyOtherFunction(); err != nil { t.Errorf("Error calling MyOtherFunction: %v", err) } }In this example, we test if MyOtherFunction() returns nil error. If it returns an error, we use Errorf to print an error message with the actual error value. The package library of TB and Errorf is "testing".