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 package, like so:
// Package types provides shared types used across the application.
package types
This setup works well, and godoc generates the package documentation as expected. However, when I move the same package comment to another file within the types package (e.g., user.go), godoc does not pick up the package comment, and the package documentation is not generated.
I've adhered to the same comment formatting and placement in both files, yet godoc only recognizes the package comment when it's in doc.go. Is this the standard behavior? If so, why does this standard promote creating numerous "additional" doc files? Is there a known issue with godoc not recognizing package comments in other files?
EDIT: I run godoc using:
godoc -play -http ":6060"
and the normal file, which comment is not recognized is this one:
// Package types provides shared types used across the application.
package types
import (
"fmt"
"go.mongodb.org/mongo-driver/bson/primitive"
)
const USER string = "user"
type User struct {
ID primitive.ObjectID `json:"id" bson:"_id"`
Name string `json:"name" bson:"name"`
LastName string `json:"lastName" bson:"lastName"`
Email string `json:"email" bson:"email"`
Password string `json:"password" bson:"password"`
}