如何在Godoc中包含可播放的示例
您如何使Golang示例可玩 我有以下代码:如何在Godoc中包含可播放的示例,go,Go,您如何使Golang示例可玩 我有以下代码: func Example_authenticate() { fmt.Println("hello") // Output: JSON } 我需要在某个地方添加可播放的代码才能在文档中获取此信息吗?您必须使用-play标志运行godoc: $ godoc --help .......... -play=false: enable playground in web interface 例如,运行godoc-http=:9020-
func Example_authenticate() {
fmt.Println("hello")
// Output: JSON
}
我需要在某个地方添加可播放的代码才能在文档中获取此信息吗?您必须使用
-play
标志运行godoc
:
$ godoc --help
..........
-play=false: enable playground in web interface
例如,运行godoc-http=:9020-play
,然后转到http://localhost:9020/pkg/encoding/json/#example_Unmarshal
要在本地安装godoc
:
go get code.google.com/p/go.tools/cmd/godoc
在本地godoc中,你是指godoc.org?不用于为我的包生成
godoc
,这是主godoc.org,但我希望我自己的包godoc与play一起使用。这可能吗?@激情开发者这取决于运行游乐场的本地版本,因此您必须在启用游乐场的情况下运行自己的本地godoc服务器。