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
84
questions
2
votes
0
answers
140
views
Are runnable examples supported for pkgsite locally?
I have the following "whole file" example that works locally without issue:
func Example_should_be_runnable() {
o := bytes.NewBufferString("")
// RootCmd() just wraps &...
0
votes
0
answers
126
views
Godoc Not Generating Package Documentation from Comments in Files Other than doc.go
I am working on a Go project and utilizing godoc to generate documentation for my packages. I have a package named types and initially placed the package comment in a doc.go file within the types ...
0
votes
2
answers
377
views
Best way to link to another package in doc.go files
What's the best way to link to a doc in another package when writing package docs in a doc.go file? Unfortunately, the normal approach of referencing an imported package doesn't work in doc.go files ...
1
vote
1
answer
595
views
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 ...
3
votes
1
answer
296
views
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 ...
3
votes
1
answer
281
views
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 ...
0
votes
1
answer
133
views
Go Doc is indenting/grouping functions unexpectedly. What is causing it?
Go Doc is indenting/making a group without me knowingly telling it to.
Here is a screenshot from my browser showing the problem. The four Parse functions should not be indented:
What is causing this ...
7
votes
3
answers
1k
views
Viewing Example functions with `go doc` command?
If I view a package's documentation via the web at https://pkg.go.dev, the page includes Example test functions. The output of go doc -u -all for a package does not. Is it possible to have such ...
0
votes
0
answers
142
views
Go AST: Why is FuncDecl.Recv is of type *FieldList
In the go/ast docs the type of FuncDecl.Recv is *FieldList instead of *Field. It parses multiple receivers just fine.
But compiler throws error on passing multiple recievers
method has multiple ...
2
votes
0
answers
214
views
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(...
1
vote
0
answers
162
views
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/...
1
vote
0
answers
54
views
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 ...
1
vote
0
answers
278
views
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 ...
0
votes
2
answers
476
views
Go doc for simple hello world program
How to write a go program such that it has a simple doc for it
example
package HelloWorld
import "fmt"
func HelloWorld() {
fmt.Println("hello world")
}
after making changes ...
0
votes
1
answer
450
views
SIMPLE godoc Hello world
Trying to serve a godoc on a simple, flat code folder. The online docs do not explain how to achieve this SIMPLE task.
So, creating this simple structure,
/tmp/testgodoc$ tree
.
└── src
├── main (...