https://github.com/neilotoole/gohdoc
gohdoc opens a package's godoc in the browser
https://github.com/neilotoole/gohdoc
Last synced: 6 months ago
JSON representation
gohdoc opens a package's godoc in the browser
- Host: GitHub
- URL: https://github.com/neilotoole/gohdoc
- Owner: neilotoole
- License: mit
- Created: 2019-01-27T17:49:07.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-09-24T18:16:57.000Z (about 2 years ago)
- Last Synced: 2025-03-25T05:42:00.543Z (7 months ago)
- Language: Go
- Size: 4.17 MB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://goreportcard.com/report/github.com/neilotoole/gohdoc)
# gohdoc
`gohdoc` opens a package's godoc in the browser.
> **Note**
> `gohdoc` hasn't been updated in years, and the Go toolchain has since moved forward significantly. In particular,
> `gohdoc` doesn't take account of [Go modules](https://go.dev/blog/using-go-modules), which means it really doesn't work as desired any more.
> I doubt that updating `gohdoc` will any time soon be my highest open-source priority. Sorry, `gohdoc`.## Why?
To verify that your package's godoc is formatted correctly in the browser.
Or because you prefer to view godoc in the browser.## Overview
In your package dir, execute `gohdoc .` (or just `gohdoc`). This will open the current package's
godoc in the browser, starting a godoc http server if necessary. You can specify absolute and
relative paths, or full or partial package names, e.g. `gohdoc fmt` or `gohdoc encoding/jso`.
Fragments are preserved, so `gohdoc fmt#Println` will work. Use `gohdoc -search` or `gohdoc -list`
to interrogate the set of packages on the godoc server.### Why?
The original purpose was to swiftly verify that the godoc I was writing for my package
was properly formatted in godoc's HTML rendering. But then I also found it useful for
generically opening godoc in the browser.## Install
`gohdoc` is installed in the usual Go fashion:
```bash
$ go get -u github.com/neilotoole/gohdoc
```## Usage
Use `gohdoc -help` to see something like this:
```
gohdoc opens a package's godoc in the browser.gohdoc (go http doc) looks for an existing godoc http server, and uses that if
available. If not, gohdoc will start a godoc http server on port 6060; override
with envar GODOC_HTTP_PORT. The godoc http server will continue to run after
gohdoc exits, but can be killed using gohdoc -killall.Usage:
gohdoc open current pkg godoc in browser
gohdoc . same as above
gohdoc my/sub/pkg
gohdoc /go/src/github.com/my/pkg
gohdoc fmt
gohdoc fmt#Println open fmt#Println godoc
gohdoc .#MyFunc open current pkg #MyFunc godoc
gohodc '#MyFunc' same as above, quoted because bashInterrogate the godoc server's package list:
gohdoc -list list all packages on the godoc http server
gohdoc -listv same as -list, but also print pkg url
gohdoc -search pkg/name list packages that match arg
gohdoc -searchv pkg/name same as -search, but also print pkg urlList or kill running godoc servers:
gohdoc -servers list godoc http server processes
gohdoc -killall kill all godoc http server processesFor completeness:
gohdoc -help print this help message
gohdoc -version print gohdoc versionThe -debug flag can be used to enable debug logging. If gohdoc spawns a godoc
http server, the -debug flag will also print that server's verbose output.Note that a godoc http server is tied to a particular GOPATH. If your pkg is
unexpectedly not found, verify that the godoc http server is started on the
correct GOPATH. If necessary, use gohdoc -killall and rerun gohdoc inside the
appropriate GOPATH.
```## Feedback
Bugs, feature requests etc, open an [issue](https://github.com/neilotoole/gohdoc/issues).
Make sure to run `gohdoc` with the `-debug` flag and include the output in the issue.