go-config-logging

Load environment-based configuration and initialize structured slog logging for Go services.

Updated Jan 8, 2026
One-click install
npx skills add https://github.com/OlegHQ/claude-config --skill go-config-logging
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-config-logging
Source: https://github.com/OlegHQ/claude-config/tree/main/go-skills-plugin/skills/go-config-logging
Command: npx skills add https://github.com/OlegHQ/claude-config --skill go-config-logging

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Go applications often rely on environment variables for configuration and require consistent, structured logging. This skill provides a clean way to load config from the environment with sensible defaults and to switch between JSON and text logging formats.

Core Features & Use Cases

  • Environment-driven config loading with sensible defaults (Port, Host, MongoURI, MongoName, etc.)
  • Structured logging with slog supporting JSON output when JSON_LOGS is enabled
  • Main.go wiring patterns and request logging middleware for production-grade Go services
  • Examples of error handling, dependency wiring, and observability in startup and request paths

Quick Start

Set the environment variables PORT, HOST, MONGO_URI, MONGO_NAME, and JSON_LOGS, then run the Go application to bootstrap configuration and logging.

Frequently Asked Questions about go-config-logging

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I load environment variables for configuration in a Go server?

Loading environment variables in Go involves parsing settings like Port, Host, and MongoURI with sensible defaults. This skill handles environment-driven config loading at app startup, validating inputs before wiring dependencies in main.go.

What's the best way to set up structured logging in Go microservices?

Structured logging in Go microservices is best set up using the slog package. This skill initializes a JSON or text slog logger based on the JSON_LOGS environment variable and provides request logging middleware for production observability.

Can I use slog for JSON logging in a standalone Go application?

Yes, you can use slog for JSON logging in standalone Go applications. The skill configures slog to output structured JSON logs when the JSON_LOGS environment variable is enabled, otherwise defaulting to standard text format logging.

How do I wire dependencies in main.go for a Go service with MongoDB?

Wiring dependencies in main.go for a Go service requires loading environment config like MongoURI and MongoName first. This skill provides patterns to connect MongoDB dependencies, initialize logging, and handle startup errors before serving requests.

Does this Go config approach work for both microservices and standalone servers?

Yes, this environment-based config and logging approach works for both microservices and standalone servers. It applies universally to app startup, config validation, logging setup, and dependency wiring across different types of Go services.