Home > Backend Development > Golang > Go File Naming Conventions: Best Practices for File Names?

Go File Naming Conventions: Best Practices for File Names?

Patricia Arquette
Release: 2024-12-02 15:34:11
Original
967 people have browsed it

Go File Naming Conventions: Best Practices for File Names?

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:

  1. Files beginning with "." or "_" are ignored by the go tool.
  2. Files with the "_test.go" suffix are only compiled and run by the go test tool.
  3. 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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template