golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
121.14k stars 17.37k forks source link

proposal: cmd/go: doc -http should start a pkgsite instance and open a browser #68106

Open adonovan opened 2 weeks ago

adonovan commented 2 weeks ago

The go doc command displays documentation to stdout, which is handy for quick forays for a single package or symbol, but for extended reading a browser is more convenient, as it has better typography and linked cross-references. We propose that go doc -http should start a pkgsite instance in the background (if one is not running already) and open a web browser to the correct URL for the package or symbol.

The pkgsite program is currently rather large and slow to start as it was designed as a long-lived server for a large corpus on Google Cloud. Issue #61399 tracks the work so slim it down and reduce dependencies.

Open questions:

@rsc @matloob

gabyhelp commented 2 weeks ago

Similar Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

qiulaidongfeng commented 1 week ago

I would like know to run go doc -http, which starts a pkgsite process and opens a browser, then waits for the syscall.SIGINTsignal, and when it receives the signal, first close the pkgsite process and then exit itself ,how?

adonovan commented 1 week ago

We could certainly make go doc -http block until interrupted before terminating the server. And perhaps that's the least surprising interface, as many Go commands that take an -http flag block indefinitely.