我想要给一个包添加一个例子,并通过go test
运行,但是这个例子从未被执行。
例如,请参见此代码片段:https://gist.github.com/85469ecc65bb5bb85857
这个代码片段包含example_test.go
:
package cow_test
import (
cow "gist.github.com/85469ecc65bb5bb85857"
)
func Example() {
cow.Poke()
}
然而当我运行这个时:
# go test -v example_test.go
testing: warning: no tests to run
PASS
ok command-line-arguments 0.002s
然而,标准库中的其他包都可以正常使用:
# cd /usr/lib/go/src/errors
# go test -v example_test.go
=== RUN: Example
--- PASS: Example (0.00s)
PASS
ok command-line-arguments 0.002s
我的例子有什么问题?