On Sat, Mar 27, 2021 at 4:55 PM Hotei <hotei1...@gmail.com> wrote: > Could use a little help figuring out how to attack the following problem: > > I normally run godoc locally with $godoc -http=":6060"& and then browse it > with chrome. > > Many years ago that method broke for a while as godoc was "reinvented" > but then it came back pretty much the same as before. A few weeks ago I > converted a lot of old code to use modules. Now that I've converted my > local packages tree to modules I find that the same godoc code I've been > using with no problem before can only find the packages in the official > source 1.16.* tree. I don't know if this is a bug or a feature but if > possible I'd like to find a way so that the old method still works. Is > there a work-around? Sorry if this ground has been covered before. There's > no error message to reference, just the absence of my source (and that of > others from golang.org, github.com etc) in the listing. It's possible > I'm not using the latest & greatest godoc but it has moved around a bit the > last few years so I'm not 100% sure what the canonical version is right now. >
I use golang.org/x/tools/cmd/godoc, documentation at https://pkg.go.dev/golang.org/x/tools/cmd/godoc. AFAIK that is the canonical version. It honors the GOPATH env var. On my system I set that to ~/go and the godoc server shows me all the packages anchored below $GOPATH/src as well as the Go stdlib. I don't know how, or even if it is possible, to have a single godoc server handle multiple modules anchored outside of the GOPATH directory. In fact, just setting GOPATH to the root of a Go project outside of the usual GOPATH directory, and which uses modules, causes the godoc server to complain and not serve any documentation for the project. Also, rather annoyingly, you can't just create a symlink from $GOPATH/src/whatever to the actual directory containing the project. That is, godoc doesn't appear to honor symlinks in $GOPATH/src. I had to actually copy one of the projects I work on whose source is not beneath $GOPATH/src rather than create a symlink to it. That seems like a bug to me; even if you ignore that having to create a symlink in the first place is undocumented. -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD8H76qCcVmYBcx_OTWEBLB6VAA5v%3Dch9OYwB2dwfV32tw%40mail.gmail.com.