In Go, there are specific conventions established for naming packages. These guidelines include avoiding underscores between words and using lowercase throughout. However, does this convention extend to filenames as well?
The answer is generally yes. When it comes to naming files in Go, it is recommended to adhere to the same convention used for packages. This means using lowercase letters without any underscores.
Additionally, it is common practice in Go to place each struct within its own individual file. The filename is then typically named after the struct itself. For example, if you have a struct named WebServer, it would be placed in a file called web_server.go.
Furthermore, there are additional guidelines to consider when naming files in Go:
These conventions and guidelines aim to ensure consistency and adherence to best practices within the Go community.
The above is the detailed content of How Should Filenames Be Structured in Go?. For more information, please follow other related articles on the PHP Chinese website!