원클릭으로
go
// Google's official Go style guide. Covers gofmt formatting, naming conventions, error handling, interfaces, concurrency patterns, and package organization. Enforces idiomatic Go code with short variable names and explicit error checks.
// Google's official Go style guide. Covers gofmt formatting, naming conventions, error handling, interfaces, concurrency patterns, and package organization. Enforces idiomatic Go code with short variable names and explicit error checks.
| name | go |
| description | Google's official Go style guide. Covers gofmt formatting, naming conventions, error handling, interfaces, concurrency patterns, and package organization. Enforces idiomatic Go code with short variable names and explicit error checks. |
Official Google Go coding standards for idiomatic, maintainable code.
gofmt before commit — formatting is non-negotiablei, err, ctx| Element | Convention | Example |
|---|---|---|
| Packages | lowercase | package user |
| Files | lowercase_underscore | user_service.go |
| Types | UpperCamelCase | UserService |
| Functions/Methods | UpperCamelCase (exported) | GetUser |
| Functions/Methods | lowerCamelCase (unexported) | getUserByID |
| Variables | lowerCamelCase | userCount |
| Constants | UpperCamelCase or UPPER_SNAKE | MaxRetries |
| Interfaces | UpperCamelCase + -er suffix | Reader, Writer |
// ✓ CORRECT - short names in small scopes
for i := 0; i < 10; i++ {
// ...
}
// ✓ CORRECT - descriptive names in larger scopes
func ProcessUserData(userRepository UserRepository) error {
// ...
}
// ✗ INCORRECT - unnecessarily long
for index := 0; index < 10; index++ {
// ...
}
// ✓ CORRECT - check every error
user, err := getUser(id)
if err != nil {
return nil, fmt.Errorf("failed to get user: %w", err)
}
// ✗ INCORRECT - ignoring errors
user, _ := getUser(id)
// ✓ CORRECT - multiple return values
func GetUser(id int) (*User, error) {
// ...
}
// ✓ CORRECT - named return values for clarity
func ParseConfig(path string) (cfg *Config, err error) {
// ...
}
// ✓ CORRECT - small, focused interfaces
type Reader interface {
Read(p []byte) (n int, err error)
}
// ✓ CORRECT - accept interfaces, return structs
func ProcessData(r Reader) (*Result, error) {
// ...
}
// ✓ CORRECT - defer for cleanup
func ReadFile(path string) ([]byte, error) {
f, err := os.Open(path)
if err != nil {
return nil, err
}
defer f.Close()
return io.ReadAll(f)
}
// ✓ CORRECT - use context for cancellation
func ProcessItems(ctx context.Context, items []Item) error {
for _, item := range items {
select {
case <-ctx.Done():
return ctx.Err()
default:
if err := process(item); err != nil {
return err
}
}
}
return nil
}
// ✓ CORRECT - buffered channels when appropriate
results := make(chan Result, len(items))
// ✓ CORRECT - package comment
// Package user provides user management functionality.
package user
// ✓ CORRECT - group imports
import (
"context"
"fmt"
"github.com/pkg/errors"
"myapp/internal/db"
)
| Mistake | Correct Approach |
|---|---|
| Ignoring errors | Check every error |
| Long variable names in loops | Use short names (i, j) |
| Panic for normal errors | Return errors |
| Naked returns | Use explicit returns |
| Not running gofmt | Always format code |
| Underscores in package names | Use single lowercase word |
npx skills add testdino-hq/google-styleguides-skills/go
See go.md for complete details, examples, and edge cases.
Complete collection of Google's official style guides for 17 languages. Includes TypeScript, JavaScript, Python, Java, Go, C++, C#, Swift, Objective-C, HTML/CSS, AngularJS, Shell, R, Common Lisp, Vim Script, JSON, and Markdown. Production-ready coding standards used across Google's engineering organization, formatted for AI agent consumption.
Google's official AngularJS style guide. Covers controllers, services, directives, modules, dependency injection, and AngularJS 1.x best practices.
Google's official Common Lisp style guide. Covers naming conventions, formatting, macros, packages, documentation strings, and Lisp best practices.
Google's official C++ style guide. Covers headers, naming conventions, formatting, classes, memory management, RAII, smart pointers, and modern C++ features.
Google's official C# style guide. Covers naming conventions, formatting, LINQ, async/await, XML documentation, and .NET best practices.
Google's official HTML/CSS style guide. Covers formatting, naming, semantics, accessibility, and best practices for web markup and styling.