package cluster
import "fmt"
func A() error {
return fmt.Errorf("a", 1) // 这行代码应该报错
}
package cluster
import (
"testing"
)
func TestT(t *testing.T) {
A()
}
运行 TestT 函数会报错,fmt.Errorf call has arguments but no formatting directives 。
package clusterrolebinding
import (
"xx/pkg/controller/cluster"
"testing"
)
func TestT(t *testing.T) {
cluster.A()
}
但是在另外一个包里面运行 TestT 函数就不报错了,正常运行。