Go File Naming Conventions
While Go has conventions for naming packages, are there any for file names? Do you follow the Java practice of putting a single struct in a single file, naming the file after the struct?
Conventions
Go does indeed have some guidelines for file naming:
- Files beginning with "." or "_" are ignored by the go tool.
- Files with the "_test.go" suffix are only compiled and run by the go test tool.
- Files with OS or architecture-specific suffixes inherit the same constraints. For example, "name_linux.go" builds only on Linux, while "name_amd64.go" builds only on AMD64 architecture. This is equivalent to using a // build amd64 line at the file's start.
For more details, refer to the Go documentation: https://pkg.go.dev/cmd/go
The above is the detailed content of Go File Naming Conventions: Best Practices for File Names?. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn