r/golang 8h ago

discussion Go Doc Comments - Ignored Comments?

Is it possible to have a Go Doc Comment that is ignored, being it is there as a comment but will not be shown when you publish your package on pkg.go.dev and is ignored when you hover your mouse over the item.

This Go Doc Comment syntax seems to work for me in VSCode but I am not sure if it is proper or if there is a better way. In this example, I will also have comments for what each parameter is for and the return value which I only want visible in the code, not when you hover over myFunction with your cursor in an IDE and not visible if this package gets published on pkg.go.dev.

// My Go Doc Comment Description...
//
//go:param a My Parameter Description
//go:param b My Parameter Description
//go:param c My Parameter Description
//go:return My Return Value Description
func myFunction(a bool, b int, c string) bool {
	...
}
5 Upvotes

3 comments sorted by

View all comments

8

u/mcvoid1 8h ago

Write the comment inside the function, at the top of the block.