private go documentation server similar to https://pkg.go.dev

770 views
Skip to first unread message

brainman

unread,
Sep 10, 2022, 5:28:35 PM9/10/22
to golang-nuts
Hello Everyone,

I would like to run go documentation server that have access to my private code.

Is it possible to do?

I am happy to run the server myself, if it is easy to setup, and if it requires no maintenance.

I am also happy to use external company if they provide that kind of service. Are there companies that do that?

I looked for the source code for

https://pkg.go.dev

and I cannot find it.

Thank you.

Alex

peterGo

unread,
Sep 10, 2022, 6:01:03 PM9/10/22
to golang-nuts

Rob Pike

unread,
Sep 10, 2022, 10:20:37 PM9/10/22
to peterGo, golang-nuts
It would be nice if gofmt still had its -http option. You could run an
old version.

-rob
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/80e83a7d-b757-4b28-971b-619d24233eccn%40googlegroups.com.

brainman

unread,
Sep 11, 2022, 4:09:02 AM9/11/22
to golang-nuts
Thanks for the link, peterGo.

Looks complicated to configure and run.

I will try to run it when I have time.

Alex

brainman

unread,
Sep 11, 2022, 4:11:02 AM9/11/22
to golang-nuts
Thanks for your suggestion, Rob.

I just use go doc command.

The website is for my colleagues.

Alex

Jan Mercl

unread,
Sep 11, 2022, 4:40:01 AM9/11/22
to Rob Pike, golang-nuts
On Sun, Sep 11, 2022 at 4:20 AM Rob Pike <r...@golang.org> wrote:

> It would be nice if gofmt still had its -http option. You could run an
> old version.

AFAICT, the option is still there. We're using it at work, installed on our gitlab server.

        me@3900x:~$ go install -v golang.org/x/tools/cmd/godoc@latest
        golang.org/x/tools/godoc/analysis
        golang.org/x/mod/semver
        golang.org/x/tools/internal/event/label
        golang.org/x/sys/execabs
        github.com/yuin/goldmark/util
        golang.org/x/tools/godoc/vfs
        golang.org/x/tools/godoc/static
        golang.org/x/tools/internal/event/keys
        golang.org/x/tools/internal/typeparams
        golang.org/x/net/context/ctxhttp
        golang.org/x/tools/playground
        golang.org/x/tools/godoc/redirect
        golang.org/x/tools/internal/event/core
        golang.org/x/tools/godoc/util
        golang.org/x/tools/godoc/vfs/gatefs
        golang.org/x/tools/godoc/vfs/httpfs
        golang.org/x/tools/godoc/vfs/mapfs
        golang.org/x/tools/godoc/vfs/zipfs
        golang.org/x/tools/internal/event
        golang.org/x/tools/internal/gocommand
        github.com/yuin/goldmark/text
        github.com/yuin/goldmark/ast
        github.com/yuin/goldmark/renderer
        github.com/yuin/goldmark/parser
        github.com/yuin/goldmark/renderer/html
        github.com/yuin/goldmark
        golang.org/x/tools/godoc
        golang.org/x/tools/cmd/godoc
        me@3900x:~$ go version -m $GOPATH/bin/godoc
        /home/me/bin/godoc: go1.19.1
        path golang.org/x/tools/cmd/godoc
        mod golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
        dep github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=
        dep golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
        dep golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
        dep golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
        build -compiler=gc
        build CGO_ENABLED=1
        build CGO_CFLAGS=
        build CGO_CPPFLAGS=
        build CGO_CXXFLAGS=
        build CGO_LDFLAGS=
        build GOARCH=amd64
        build GOOS=linux
        build GOAMD64=v1
        me@3900x:~$ godoc -http :6060 &
        [1] 1554
        me@3900x:~$ using module mode; GOMOD=/dev/null
       
        me@3900x:~$


-j

Rob Pike

unread,
Sep 11, 2022, 6:50:57 AM9/11/22
to Jan Mercl, golang-nuts
Yes, godoc. I need more sleep.

-rob

tapi...@gmail.com

unread,
Sep 11, 2022, 9:42:23 PM9/11/22
to golang-nuts
I don't know if it satisfies your need, but you can try Golds: https://go101.org/apps-and-libs/golds.html

brainman

unread,
Sep 12, 2022, 4:01:32 AM9/12/22
to golang-nuts
Thank you for instructions.

I managed to run godoc.

But godoc only displays standard library packages.

Is it possible to configure godoc so it displays packages stored in private github repos ?

Thank you.

Alex

Steve Mynott

unread,
Sep 12, 2022, 4:20:25 AM9/12/22
to brainman, golang-nuts
When I started "godoc -http=localhost:6060 -index" in a local repo it did read the go.mod file and display our docs for local github repos.

I wonder if it's go workspace aware yet?

S

--
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...@googlegroups.com.


--
Steve Mynott <steve....@gmail.com>
rsa3072/629FBB91565E591955B5876A79CEFAA4450EBD50

Jan Mercl

unread,
Sep 12, 2022, 4:31:11 AM9/12/22
to brainman, golang-nuts
On Mon, Sep 12, 2022 at 10:01 AM brainman <alex.b...@gmail.com> wrote:

> I managed to run godoc.
>
> But godoc only displays standard library packages.
>
> Is it possible to configure godoc so it displays packages stored in private github repos ?

I use it with no configuration, '$ GO111MODULE=off godoc -http :6060
&` in particular, and it also shows all packages in $GOPATH. Maybe
setting GOPATH is the configuration you need.

brainman

unread,
Sep 12, 2022, 4:59:52 AM9/12/22
to golang-nuts
Thank you Steve.

Indeed. If I run godoc from a directory inside of a repo, then godoc displays new section called "Third party". The section displays all my module code and all its dependencies.

Unfortunately I have about hundred of repos on Github containing independent projects working on by different teams. So I don't see how I can use godoc in that environment.

Alex

brainman

unread,
Sep 12, 2022, 5:00:54 AM9/12/22
to golang-nuts
You probably run godoc from inside your module directory.

Alex

brainman

unread,
Sep 12, 2022, 5:04:48 AM9/12/22
to golang-nuts
Thanks for the link. I briefly looked at that program, and I cannot even figure it out how I can use it for my purpose - serve documentation for about hundred of private github repos.

Alex

Sebastien Binet

unread,
Sep 12, 2022, 5:50:04 AM9/12/22
to brainman, golang-nuts
On Mon Sep 12, 2022 at 11:04 CET, brainman wrote:
> Thanks for the link. I briefly looked at that program, and I cannot even
> figure it out how I can use it for my purpose - serve documentation for
> about hundred of private github repos.

I believe you can do this with this maintained fork of godoc.org:

- https://sr.ht/~sircmpwn/godocs.io/
- https://godocs.io

it can look for a local Go module cache:

- https://sr.ht/~sircmpwn/godocs.io/#viewing-documentation-locally

hth,
-s

brainman

unread,
Sep 23, 2022, 1:32:07 AM9/23/22
to golang-nuts
Thank you Sebastian,

That might actually work for me. I will play with it to see if it suits us. I still wish I can just use https://pkg.go.dev , but we cannot have everything.

I also want to thank you for writing http://github.com/go-daq/canbus . I was using your package to control some equipment from Raspberry PI.

Alex

brainman

unread,
Sep 23, 2022, 2:06:57 AM9/23/22
to golang-nuts
I did not have GO111MODULE set.

a@spot:~$ env | grep GO
GOROOT_BOOTSTRAP=/home/a/go1.18.5
GOROOT=/home/a/go
GOPATH=/home/a
a@spot:~$

and I use current Go tip.

godoc only shows "Third party" section if I am inside of any go module directory, but not in /tmp .

a@spot:~$ cd /tmp
a@spot:/tmp$ godoc -http :8080
using module mode; GOMOD=/dev/null
^C
a@spot:/tmp$ cd ~/src/golang.org/x/sys/
a@spot:~/src/golang.org/x/sys$ godoc -http :8080
using module mode; GOMOD=/home/a/src/golang.org/x/sys/go.mod
go: no module dependencies to download
^C
a@spot:~/src/golang.org/x/sys$

Note how GOMOD setting changes in godoc output as I change my directories.

If I use GO111MODULE environment variable

a@spot:~$ cd /tmp
a@spot:/tmp$ GO111MODULE=off godoc -http :8080
using GOPATH mode
^C
a@spot:/tmp$ cd ~/src/golang.org/x/sys/
a@spot:~/src/golang.org/x/sys$ GO111MODULE=off godoc -http :8080
using GOPATH mode
^C
a@spot:~/src/golang.org/x/sys$

then godoc displays "using GOPATH mode" message, and displays all packages I have in my GOPATH on one large single page.

This is not useful in my scenario, because we have many independent teams working on many independent Go repos. I don't see how it would be possible for me to automatically download and keep up-to-date then all into single GOPATH. And it would be overwhelming to see all our packages on one single page. And godoc does not displays package versions.

But thanks for trying.

Alex
On Monday, 12 September 2022 at 18:31:11 UTC+10 Jan Mercl wrote:

Sebastien Binet

unread,
Sep 23, 2022, 5:57:15 AM9/23/22
to brainman, golang-nuts
On Fri Sep 23, 2022 at 07:32 CET, brainman wrote:
> Thank you Sebastian,
>
> That might actually work for me. I will play with it to see if it suits
> us.
> I still wish I can just use https://pkg.go.dev , but we cannot have
> everything.
>
> I also want to thank you for writing http://github.com/go-daq/canbus . I
> was using your package to control some equipment from Raspberry PI.

the project I developed it for is now long gone, but I am glad this
could be of some help.

-s
Reply all
Reply to author
Forward
0 new messages