بنقرة واحدة
go-conventions
Go coding conventions, best practices, and style guidelines. Use when writing or reviewing Go code.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Go coding conventions, best practices, and style guidelines. Use when writing or reviewing Go code.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | go-conventions |
| description | Go coding conventions, best practices, and style guidelines. Use when writing or reviewing Go code. |
Follow these conventions when writing Go code for this project.
package at the top of every filecamelCase (e.g., userName, maxRetries)PascalCase for exported, camelCase for unexported (e.g., MaxRetries, defaultTimeout)PascalCase for exported (e.g., GetUser), camelCase for unexported (e.g., processData)PascalCase (e.g., UserService, Config)PascalCase, often with -er suffix (e.g., Reader, Writer)fmt.Errorf or errors.Wrap_// Good
if err != nil {
return fmt.Errorf("failed to process user %d: %w", userID, err)
}
// Bad
_ = mightFail() // Never ignore errors
name_test.go alongside name.goTestFunctionNamerequire/assert from testifyfunc TestProcessUser(t *testing.T) {
tests := []struct {
name string
input User
want Result
wantErr bool
}{
{"valid user", user, result, false},
{"invalid email", invalidUser, nil, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := ProcessUser(tt.input)
if tt.wantErr {
require.Error(t, err)
return
}
require.NoError(t, err)
require.Equal(t, tt.want, got)
})
}
}
context.Context as first argumentcontext.TODO() when uncertainfunc FetchUser(ctx context.Context, id int) (*User, error) {
req, err := http.NewRequestWithContext(ctx, "GET", "/users/"+strconv.Itoa(id), nil)
// ...
}
sync.WaitGroup for coordinating goroutines-race flagimport (
// stdlib
"context"
"fmt"
"io"
"os"
// external
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
// internal
"github.com/alantheprice/ledit/pkg/db"
"github.com/alantheprice/ledit/pkg/service"
)
init() for one-time setup onlyNewThing() *ThingPython 3.11+ key decisions and patterns. Use when writing Python code.
Rust 2021 edition coding conventions. Use when writing or reviewing Rust code.
TypeScript 5.x / JavaScript ES2022+ coding conventions. Use when writing or reviewing TypeScript/JavaScript code.
Repro-first bug investigation process with root-cause validation and fix planning.
Keep user-facing documentation aligned with current behavior.
Pre-release validation checklist with go/no-go recommendation.