如何在Godoc中包含具有可玩性的Example

How do you make Golang example playable?

I have a below code:

func Example_authenticate() {
    fmt.Println("hello")
    // Output: JSON
}

Do I need to add playable code somewhere to get this in Doc?

You have to run godoc with the -play flag:

$ godoc --help
..........
  -play=false: enable playground in web interface

For example run godoc -http=:9020 -play then go to http://localhost:9020/pkg/encoding/json/#example_Unmarshal

To install godoc locally:

go get code.google.com/p/go.tools/cmd/godoc