Home >Backend Development >Golang >How Should Go Filenames and Struct Placement Adhere to Go's Naming Conventions?
Go File Naming Conventions
In Go, package naming conventions dictate the use of lowercase words without underscores. However, the question arises whether these conventions extend to filenames. Additionally, should one struct be placed in a single file, similar to a Java class, with the filename reflecting the struct name?
The Go community has established several guidelines for filenames:
For the example provided, a struct named "WebServer" should be placed in a file named "web_server.go" as follows the convention of lowercase words separated by underscores.
Refer to the official Go documentation (https://pkg.go.dev/cmd/go) for further details on filename conventions.
The above is the detailed content of How Should Go Filenames and Struct Placement Adhere to Go's Naming Conventions?. For more information, please follow other related articles on the PHP Chinese website!