Questions tagged [godoc]

GoDoc hosts documentation for Go packages on Bitbucket, GitHub, Google Project Hosting and Launchpad. It can extract and generate documentation for Go programs.

Godoc extracts and generates documentation for Go programs.

Godoc parses Go source code - including comments - and produces documentation as HTML or plain text. The end result is documentation tightly coupled with the code it documents. For example, through godoc's web interface you can navigate from a function's documentation to its implementation with one click.

It has two modes.

Without the -http flag, it runs in command-line mode and prints plain text documentation to standard output and exits. If both a library package and a command with the same name exists, using the prefix cmd/ will force documentation on the command rather than the library package. If the -srcflag is specified, godoc prints the exported interface of a package in Go source form, or the implementation of a specific exported language entity.

References :

http://godoc.org/golang.org/x/tools/cmd/godoc

81 questions
5
votes
1 answer

Godoc, create html for entire package

How can I use godoc to create html documentation for an entire package. i.e. recursively. At the moment when I run: godoc -html -goroot="mypath" pkg > index.html I just get an index.html that contains information on the .go files in the current…
jim
  • 8,670
  • 15
  • 78
  • 149
5
votes
1 answer

How to hide standard libs in Godoc?

I usually started the GoDoc server using "godoc -http=0.0.0.0:6060" for sharing document with stuffs. The prob is it always mix built-in libs' doc with my application's. After some search that std lib hiding feature seems not supported this moment..…
Jason Xu
  • 2,903
  • 5
  • 31
  • 54
4
votes
1 answer

how to serve godoc command on Heroku

I am trying to serve godoc -http=:[port] on Heroku server I get the following error in Heroku logs bash: godoc: command not found my Procfile looks like: web: godoc -http=:$PORT I tried to install godoc by adding the following line to the…
4
votes
1 answer

Create godoc URL with different link text

According to the "Godoc: documenting Go code" blog post: URLs will be converted to HTML links; no special markup is necessary. However, is there a way to create an HTML link with different link text than the URL?
Matthew Rankin
  • 457,139
  • 39
  • 126
  • 163
4
votes
3 answers

Automatically start godoc localhost server in OS X?

In Go, you can start HTTP server and then browse through the Go document via the specific port. For example, if you type in godoc -http=:3333 in Terminal, the localhost server starts working on port 3333 and you can then view the official Go…
Blaszard
  • 30,954
  • 51
  • 153
  • 233
3
votes
1 answer

GoDoc Example function for type/struct functions

Problem I have written some example functions located in a *_test.go file to help clarify context for standalone public functions without issue. The problem on displaying comes when writing example functions for functions tied to a…
Jadon
  • 69
  • 6
3
votes
1 answer

How to write example tests in Go?

I'm writing a test framework and would like to put examples in my documentation. For maintainability, I'd like to have these examples tested but I can't figure out how. Ideally, I would like a tested example which looks like: func TestFoo(t…
kcza
  • 63
  • 5
3
votes
1 answer

How do I run godoc locally for a module?

I'm trying to run godoc locally for a module but running into this error. It looks to me like godoc relies on go list, but doesn't run go list in a module friendly manner. ak/ (master) godoc -http=localhost:6060 using module mode;…
AaronKronberg
  • 197
  • 1
  • 7
3
votes
1 answer

godoc Example output with CRLF

I have written the following method: func (c *Component) Encode(w io.Writer){ //encodes c and writes the bytes into w, containing a few CRLF linebreaks } I also wrote the function demonstrating the encoder: func ExampleComponent_Encode() { …
M.R.
  • 49
  • 6
3
votes
1 answer

Documentation for architecture-specific Golang function

I have a function that I would like to provide an assembly implementation for on amd64 architecture. For the sake of discussion let's just suppose it's an Add function, but it's actually more complicated than this. I have the assembly version…
Michael McLoughlin
  • 1,062
  • 1
  • 11
  • 14
3
votes
2 answers

How can I generate HTML documents for all packages inside a folder using godoc

godoc -html generates documents for only one package. However, I want to ship the project with all documents for all packages, just like when I run godoc -http. With that, I could find all packages and navigate through them from the browser. Is it…
Ali Dabour
  • 135
  • 1
  • 7
3
votes
3 answers

Golang godoc - Explain group type declarations

There is a piece of GO code I have seen in the GIN library and in the Google docs that look like the following type ( T0 []string T1 []string T2 struct{ a, b int } T3 struct{ a, c int } T4 func(int, float64) *T0 T5 func(x…
Andrei
  • 1,196
  • 1
  • 11
  • 25
3
votes
0 answers

How do I get godoc to generate import dependency graphs for my project?

I have installed go on my Mac; and godoc appears to work, but when using godoc -http=... I get nice pages but without a dependency graph.
Steve Powell
  • 25,354
  • 8
  • 41
  • 44
2
votes
1 answer

Can't godoc create documentation for packages within internal folder?

In a common project structure there are folders like: /cmd /internal /pkg however when executing godoc No documentation is created for the packages within the internal folder: internal is missing between cmd and pkg Problem is: there are functions…
claus
  • 56
  • 6
2
votes
1 answer

Ignore external dependencies and standard library in `godoc` output

I have a Go project which uses Go Modules. I'd like to use godoc to generate the documentation for this project's packages. Currently, I'm using: godoc -http=":6060" This generates the documentation for the project, sure, but it also generates the…
Aquarthur
  • 609
  • 5
  • 20