Jason Xu
Jason Xu

Reputation: 2963

godoc without showing source code

I got several Go projects which is documented compatibly with godoc. We use godoc to share doc and code internally as a doc server without significant problem. However we need more control on opening code when we want to share doc with 3rd party. Is there a way to run godoc in a special mode that showing types and docs but never link to or showing source code?

I've tried

godoc -http=0.0.0.0:8090 -links=false -src=false

but not working, still can link to type definition code. Just wondering if missed sth. Go version, 1.3.

Upvotes: 2

Views: 820

Answers (1)

Not_a_Golfer
Not_a_Golfer

Reputation: 49235

The src file only refers to command line mode, not to server mode, so it won't help you. The way I see it there are a few options:

  1. Rewrite godoc for your needs and use your own fork.

  2. Don't use the server mode, render the docs in command line mode and just create a server out of that.

  3. Better yet (I'm not entirely sure 2 will work) - rewrite the templates a bit so the source code won't be linked. But you'll still need to make sure people who enter the path manually won't see the code so it will require fudging the source templates as well. or...

  4. Maybe the simplest thing - run it behind nginx or a similar reverse proxy, and make sure the /src path in the server is closed to outside visitors, or password protected or whatever. That way your internal team can still use it.

Personally I'd go with 4, it's a couple minutes of work and will be the most robust and flexible solution.

Upvotes: 2

Related Questions