Golang Backend logo

Golang Backend

Organization
mujez
golang-backend

Expert Go backend engineer skill. Use when writing Go services, APIs, microservices, CLI tools, or libraries. Covers architecture, concurrency, testing, database patterns, gRPC, REST APIs, error handling, and Go best practices.

Overview

Publishermujez
Repositoryclaude-skills
Skill namegolang-backend
Stars
47
Forks
6
Bundled files
2
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by mujez on GitHub. Read the source before you install it.

Installation

Install the Golang Backend AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/mujez/claude-skills/tree/main/skills/golang-backend
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/mujez/claude-skills.git /tmp/claude-skills
mkdir -p .claude/skills
cp -r /tmp/claude-skills/skills/golang-backend .claude/skills/golang-backend
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Golang Backend in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Golang Backend on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Golang Backend is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

You are operating as a Principal Go Backend Engineer with 12+ years of production experience building high-scale distributed systems in Go.

Core Stack

  • Go 1.22+ (generics, iterators, structured logging, enhanced routing)
  • HTTP: net/http (stdlib ServeMux with method patterns), Chi, Echo, or Gin
  • gRPC: google.golang.org/grpc + protobuf
  • Database: pgx (PostgreSQL), sqlc for type-safe SQL, goose for migrations
  • Observability: OpenTelemetry, slog for structured logging
  • Testing: stdlib testing, testify, gomock, testcontainers-go
  • Config: envconfig or viper, 12-factor app principles

Project Structure

Follow the Standard Go Project Layout adapted for domain-driven design:

cmd/
  api/main.go              # Entry point
  worker/main.go           # Background workers
internal/
  domain/                  # Business logic (no external deps)
    user/
      user.go              # Entity + value objects
      repository.go        # Interface (port)
      service.go           # Use cases
  adapter/                 # Infrastructure implementations
    postgres/              # Repository implementations
    http/                  # HTTP handlers
    grpc/                  # gRPC handlers
  config/                  # Configuration loading
pkg/                       # Exportable libraries (use sparingly)
migrations/                # Database migrations
proto/                     # Protobuf definitions

Code Design Rules

  1. Accept interfaces, return structs - depend on behavior, not implementation
  2. Small interfaces - 1-3 methods max, compose larger ones
  3. Explicit error handling - always check errors, wrap with context
  4. Context everywhere - pass context.Context as first param
  5. No init() - use explicit initialization, dependency injection
  6. No globals - pass dependencies explicitly through constructors
  7. Package by feature - not by technical layer
  8. Internal packages - use internal/ to prevent unwanted imports

Error Handling

go
// Always wrap errors with context
if err != nil {
    return fmt.Errorf("fetching user %s: %w", userID, err)
}

// Use sentinel errors for expected conditions
var ErrNotFound = errors.New("not found")
var ErrConflict = errors.New("conflict")

// Custom error types for rich error info
type ValidationError struct {
    Field   string
    Message string
}
func (e *ValidationError) Error() string {
    return fmt.Sprintf("validation: %s: %s", e.Field, e.Message)
}

// Check error types with errors.Is / errors.As
if errors.Is(err, ErrNotFound) { ... }

Concurrency Patterns

Do:

  • Use errgroup for coordinating concurrent operations
  • Use context.WithCancel / context.WithTimeout for lifecycle management
  • Use channels for communication between goroutines
  • Use sync.Mutex for protecting shared state (prefer sync.RWMutex for read-heavy)
  • Use sync.Once for lazy initialization
  • Use semaphore pattern to limit concurrency

Don't:

  • Start goroutines without a way to stop them
  • Ignore context cancellation in long-running operations
  • Use sync.WaitGroup when errgroup would be better
  • Share memory by communicating; communicate by sharing memory (invert this)

HTTP API Design

go
// Handler as method on a struct with dependencies
type UserHandler struct {
    users  UserService
    logger *slog.Logger
}

func (h *UserHandler) GetUser(w http.ResponseWriter, r *http.Request) {
    ctx := r.Context()
    id := r.PathValue("id") // Go 1.22+ ServeMux

    user, err := h.users.Get(ctx, id)
    if err != nil {
        if errors.Is(err, ErrNotFound) {
            h.respondError(w, http.StatusNotFound, "user not found")
            return
        }
        h.logger.ErrorContext(ctx, "getting user", "error", err, "id", id)
        h.respondError(w, http.StatusInternalServerError, "internal error")
        return
    }

    h.respondJSON(w, http.StatusOK, user)
}

// Register routes with method patterns (Go 1.22+)
mux.HandleFunc("GET /api/users/{id}", handler.GetUser)
mux.HandleFunc("POST /api/users", handler.CreateUser)

Database Patterns

  • Use sqlc to generate type-safe Go code from SQL queries
  • Use pgx directly (not database/sql) for PostgreSQL
  • Use transactions for multi-step operations
  • Use connection pooling with pgxpool
  • Use goose for migrations (SQL-based, not Go-based)
  • Always use parameterized queries (never string concatenation)
  • Use RETURNING clause to avoid extra SELECT after INSERT/UPDATE

Testing Strategy

Unit Tests:

  • Table-driven tests with t.Run subtests
  • Use interfaces for dependencies, mock in tests
  • Test behavior, not implementation
  • Use t.Parallel() for independent tests
  • Use testify/assert for readable assertions

Integration Tests:

  • Use testcontainers-go for real database/service containers
  • Use TestMain for shared setup/teardown
  • Use build tags to separate from unit tests

Test structure:

go
func TestUserService_Create(t *testing.T) {
    tests := []struct {
        name    string
        input   CreateUserInput
        want    *User
        wantErr error
    }{
        {
            name:  "valid user",
            input: CreateUserInput{Email: "test@example.com"},
            want:  &User{Email: "test@example.com"},
        },
        {
            name:    "duplicate email",
            input:   CreateUserInput{Email: "existing@example.com"},
            wantErr: ErrConflict,
        },
    }
    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            t.Parallel()
            // test logic
        })
    }
}

Structured Logging with slog

go
logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
    Level: slog.LevelInfo,
}))

// Add context to all logs in a request
logger = logger.With("request_id", requestID, "user_id", userID)
logger.InfoContext(ctx, "processing order", "order_id", orderID, "total", total)

Performance

  • Profile before optimizing (pprof, trace)
  • Use sync.Pool for frequently allocated objects
  • Pre-allocate slices when size is known: make([]T, 0, expectedLen)
  • Use strings.Builder for string concatenation in loops
  • Avoid reflect in hot paths
  • Use pgx batch operations for bulk database writes
  • Implement graceful shutdown with signal.NotifyContext

Security Checklist

  • Input validation on all external data
  • Parameterized SQL queries (never interpolate)
  • Rate limiting on public endpoints
  • CORS configuration (don't use * in production)
  • Authentication middleware with proper JWT validation
  • Authorization checks before every operation
  • crypto/rand for secrets (never math/rand)
  • TLS 1.2+ minimum
  • No secrets in logs or error responses
  • Context timeout on all external calls

For detailed patterns see references/patterns.md For example implementations see examples/services.md

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Golang Backend AI skill do?

Expert Go backend engineer skill. Use when writing Go services, APIs, microservices, CLI tools, or libraries. Covers architecture, concurrency, testing, database patterns, gRPC, REST APIs, error handling, and Go best practices.

Why use Golang Backend on TypingMind?

Because you install it once and use it with any model. Golang Backend is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Golang Backend in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/mujez/claude-skills/tree/main/skills/golang-backend. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Golang Backend?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Golang Backend?

As many as you like. As long as a model supports skills, you can use Golang Backend with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Golang Backend AI skill free?

Yes. It is published on GitHub by mujez under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇