Document exported functions with a comment starting with the function name:
// Add returns the sum of two integers.
// It handles negative numbers correctly.
func Add(a, b int) int {
return a + b
}
Go's documentation tools extract these comments automatically. The first sentence should be a complete summary. Start with the function name so it reads well in documentation listings.