Hosting godoc internally for private git server

2,318 views
Skip to first unread message

Kareem Gan

unread,
Oct 20, 2016, 1:27:11 PM10/20/16
to golan...@googlegroups.com
Hello.

Is it possible to host godoc internally because we have our own git server and would like to host godoc internally so we can build documentation for our golang repositories.
--
Best,

Kareem Gan
01010011 01000101

Pietro Gagliardi

unread,
Oct 20, 2016, 1:35:10 PM10/20/16
to Kareem Gan, golan...@googlegroups.com
You can go get golang.org/x/tools/cmd/godoc and run the godoc tool itself, which will imitate golang.org. This is different from godoc.org; that is harder to host locally.

--
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.
For more options, visit https://groups.google.com/d/optout.

Kareem Gan

unread,
Oct 25, 2016, 10:36:35 AM10/25/16
to golang-nuts, kare...@gmail.com
So it's not possible? It would be really helpful if someone here has done it already and share the knowledge how.

Pietro Gagliardi

unread,
Oct 25, 2016, 10:55:37 AM10/25/16
to Kareem Gan, golang-nuts
Is imitating golang.org not sufficient? It will still show you all the packages in your $GOPATH in the Packages page:

Kareem Gan

unread,
Oct 25, 2016, 10:57:58 AM10/25/16
to Pietro Gagliardi, golang-nuts
Ah. But I need it to download the repositories from my organizations enterprise github server through.

Jonathan Yu

unread,
Oct 25, 2016, 11:46:40 AM10/25/16
to Kareem Gan, Pietro Gagliardi, golang-nuts
It looks like the source code for godoc.org is available, but there's not a whole lot of instructions on use (my guess is they don't intend for it to be used in your intranet): https://github.com/golang/gddo

That means you'll need to roll up your sleeves and dig into the code, probably modifying it to handle authentication with your GitHub Enterprise installation, etc.  There's instructions on running it here: https://github.com/golang/gddo/wiki/Development-Environment-Setup

If you do go this route, consider contributing your work back into the project itself :)

To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Best,

Kareem Gan
01010011 01000101

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

For more options, visit https://groups.google.com/d/optout.



--
Jonathan Yu @jawnsy on LinkedInTwitterGitHubFacebook
“Ever tried. Ever failed. No matter. Try again. Fail again. Fail better.” — Samuel Beckett, Worstward Ho (1983) 

“In an adaptive environment, winning comes from adapting to change by continuously experimenting and identifying new options more quickly and economically than others. The classical strategist's mantra of sustainable competitive advantage becomes one of serial temporary advantage.” — Navigating the Dozens of Different Strategy Options (HBR)

Dmitry Savintsev

unread,
Oct 25, 2016, 5:24:57 PM10/25/16
to golang-nuts, kare...@gmail.com, and...@lostsig.net
that's what we do - forking https://github.com/golang/gddo and adding the custom authentication logic and fetching data from the GHE.

I'd recommend to concentrate on building and customizing gddo-server and gosrc (don't try to build everything in gddo). We changed or added the following files:
* gddo-server/main.go
- added a new command-line option tlsdir = flag.String("tlsdir", "/custom/tls/path", "directory with TLS key/certificate")
- at the end of main(), instead of appengine.Main(), put the custom authentication and http.ListenAndServeTLS with the authentication

* gosrc/newfile.go - implements fetching code from the internal Git instance
addService(&service{
pattern:         regexp.MustCompile(`^go\.corp\.company\.com/(?P<owner>[a-z0-9A-Z_.\-]+)/(?P<repo>[a-z0-9A-Z_.\-]+)(?P<dir>/.*)?$`),
prefix:          "go.corp.company.com", // custom package prefix
get:             getCustomGitDir,
getPresentation: getCustomGitPresentation,
getProject:      getCustomGitProject,
})
    and then implementation of the three getCustomGit* functions

* httputil/transport.go - adds patch for authentication GHE instance
if req.URL.Host == "git.corp.company.com" { // get token, add it to the [copy of the] request

I think that's mostly it.  I wish someone would take time to make and opensource a fork of gddo that would be free from the GHE/appenging stuff which complicates the matters somewhat when you have to host it on your own :)

Dmitry Savintsev

unread,
Oct 25, 2016, 5:27:01 PM10/25/16
to golang-nuts, kare...@gmail.com, and...@lostsig.net
s/appenging/appengine (https://cloud.google.com/appengine/)

step...@google.com

unread,
Oct 25, 2016, 7:05:18 PM10/25/16
to golang-nuts, and...@lostsig.net
Yeah, I work on godoc.org and we essentially decided not to try to support the internal usecase. The reason is that you can just use the normal godoc tool.

I recommend setting up a simple cron job to pull from github every so often and run the godoc tool. gddo is very very heavy for this small of a use case. It prides itself on efficiently managing the entire (open source) Go corpus. I plan to work on a lot of production improvements (better logging, error reporting, performance tracing) that are just not necessary for a small install. Unless your company is the size of Google, you probably just need to git pull every so often to follow dozens (or maybe even hundreds) repos for your company.

That being said, gddo does take contributions! If you want you can port it to an internal server environment and contribute back. I wouldn't necessarily recommend that though.

-- Stephen

Michael Levine

unread,
Apr 5, 2018, 1:26:24 PM4/5/18
to golang-nuts
How can I make godoc being run on local source code use the godoc templates/assets properly from a locally hosted version of godoc?

I tried the following:  $ godoc -templates="$GOPATH/src/github.com/golang/gddo/gddo-server/assets" -html path/to/local/library > ~/destination/path/library.html

I also found the following notes:

From (https://github.com/golang/gddo/wiki/Development-Environment-Setup):  "To run the gddo-server binary outside of a development environment with the source in $GOPATH/src/github.com/golang/gddo, you will need a copy of the assets directory. Use the gddo-server --assets command line flag to specify the location of the directory."

From (https://github.com/golang/tools/blob/master/godoc/README.md):  "In production, CSS/JS/template assets need to be compiled into the godoc binary. It can be tedious to recompile assets every time, but you can pass a flag to load CSS/JS/templates from disk every time a page loads:    $  godoc -templates=$GOPATH/src/golang.org/x/tools/godoc/static -http=:6060"

Is there a flag I can use when I run godoc to make the proper assets/templates get used in the generated file?  
Reply all
Reply to author
Forward
0 new messages