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
2
votes
1 answer

godoc http server doesn't seem to live reload changes

I seem to be unable to find an answer to the question, does the godoc server support live reload changes in for my own projects? According to this article it should be supported however whenever I change my code (update documentation) no changes…
Adrian Forsius
  • 1,437
  • 2
  • 19
  • 29
2
votes
1 answer

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…
Jason Xu
  • 2,903
  • 5
  • 31
  • 54
2
votes
1 answer

Documenting public methods on private structs via Godoc in Go

I have a private struct (actually more than one, I simplified a bit for this example) which I have a public function on, that satisfies a public interface. This struct is created via a factory method (NewX-style): package godocprivate type…
Peter Brennan
  • 1,366
  • 12
  • 28
2
votes
1 answer

How to show builtin types using `godoc -http=:6060`?

If I start godoc -http=:6060 and then open http://localhost:6060/pkg/builtin/#string (e.g. via a function declaration that uses string as a type somewhere), I get a big red "open /usr/local/Cellar/go/1.3.3/libexec/src/builtin: no such file or…
Felix Rabe
  • 4,206
  • 4
  • 25
  • 34
2
votes
1 answer

How to make godoc link to source on github

On the godoc site, most libraries (http://godoc.org/github.com/beego/memcache for example) link directly to the source on github. When I run the godoc tool locally, this is not the case. We also have a local godoc server for our team, and it…
pyraz
  • 113
  • 2
  • 8
1
vote
1 answer

Golang is having permission issues on my new Mac, fresh install

a little bit of context I have been working on Golang for almost 2 years now, just yesterday I got a Mac, I'm new on this OS, previously I have only worked Golang on linux, both Ubuntu and arch and the process has been straightforward, as it seems…
Andrew Alizaga
  • 124
  • 1
  • 12
1
vote
0 answers

The mechanism of runnable Go examples in pkg.go.dev

There have two examples: fun Marshal: You can see the example are not contain any button. source func ExampleMarshal() { type Item struct { Foo string } b, err := msgpack.Marshal(&Item{Foo: "bar"}) if err != nil { …
Carson
  • 6,105
  • 2
  • 37
  • 45
1
vote
0 answers

How can you use go doc without modules?

Is it possible to use go doc for a 'downloaded' package without creation of a module? ~/tt$ ls # empty ~/tt$ go install go.mongodb.org/mongo-driver/bson@latest package go.mongodb.org/mongo-driver/bson is not a main package ~/tt$ go doc…
1
vote
0 answers

godoc pass external reference file containing documentation for code without comments

Instead of comments written in the code itself, is it possible to pass an external reference file to the godoc command containing the documentation for any uncommented code? The requirement here is that we need to generate documentation for a…
user9492428
  • 603
  • 1
  • 9
  • 25
1
vote
0 answers

How to use godoc for self-defined packages

I know golang provides godoc to easily inspect go package (along with exported functions, function-level and package-level comments). It works fine for standard packages. I tried to use it for my own package. $ echo $GOPATH /home/username/go My…
Tinyden
  • 524
  • 4
  • 13
1
vote
3 answers

How to run pkg.go.dev locally as a godoc replacement?

godoc has been removed from the go standard install since 1.12 and looks like it wont be updated anytime soon. pkg.go.dev at least appears to be its successor. It also has additional documentation features like grabbing the README.md file and…
Liam Kelly
  • 3,524
  • 1
  • 17
  • 41
1
vote
2 answers

Excluding README section from godoc for Github project

I have a Github project with README.md. For the purpose of godoc, I added doc.go file but didn't mean to include the README.md in godoc. Currently the README is showing up as the first section in godoc. Is it possible to hide the README section at…
Iblisto
  • 309
  • 2
  • 7
1
vote
1 answer

Does json.Compact also validate json?

A colleague and I were trying to write the minimal logic that we needed for compacting, validating, parsing, and storing json coming from a client. Upon doing so, we realized that compacting and validating were two steps that were both being…
Jorvy
  • 69
  • 4
1
vote
1 answer

How to show “Intra-package call graph” using “godoc”

How can I show “Intra-package call graph” using godoc as described in Intra-package call graph ? I use this command $ GO111MODULE=off godoc -http=:6060 -analysis=type,pointer to start a local server and everything is fine. I just cannot find where…
shaouai
  • 55
  • 5
1
vote
0 answers

Generating documentation as static files for my/private/custom packages

I'm trying to generate the documentation for my packages in Golang. Ultimately I want to generate the documentation as part of CI/CD and host it inside our network. I know about godoc and using the instructions here I tried exactly as it states, in…
amlwwalker
  • 3,161
  • 4
  • 26
  • 47