Go example will not

I am trying to add an example to a package and run the example through go test, however this example never runs.

For example, see this meaning: https://gist.github.com/85469ecc65bb5bb85857

The bottom line is example_test.go:

package cow_test

import (
    cow "gist.github.com/85469ecc65bb5bb85857"
)

func Example() {
    cow.Poke()
}

But when I run this:

# go test -v example_test.go 
testing: warning: no tests to run
PASS
ok      command-line-arguments  0.002s

However, other packages from stdlib work just fine:

# 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

What is wrong with my example?

+4
source share
1 answer

From the documentation :

Examples of functions without output comments are compiled but not executed.

Add output comment:

func Example() {
    junk.Poke()
    // Output: MOOOO!
}
+12
source

All Articles