gs_conf

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package gs_conf provides a layered configuration system for Go-Spring applications. It merges multiple configuration sources into a single layered property set, supporting profile-specific files and optional imports of additional configuration files.

This implementation follows the Spring Boot layered configuration model, where configuration sources have a well-defined precedence order, and higher-priority sources override lower-priority ones when the same key appears in multiple places.

Precedence Order (Highest → Lowest)

Configuration sources are organized into layers according to priority:

  1. **Command-line arguments** - Highest precedence
  2. **Operating system environment variables**
  3. **Profile-specific configuration** (`app-{profile}.yaml` etc.) - Imports declared in profile configuration files (`spring.app.imports`) - The profile-specific configuration file itself
  4. **Application base configuration** (`app.yaml` etc.) - Imports declared in application configuration files (`spring.app.imports`) - The base application configuration file itself
  5. **Built-in default properties** - Lowest precedence

Index

Constants

View Source
const CommandArgsPrefix = "GS_ARGS_PREFIX"

CommandArgsPrefix defines the environment variable name used to override the default option prefix. This allows users to customize the prefix used for command-line options if needed.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Properties *flatten.Properties
}

AppConfig represents the layered configuration of an application.

func NewAppConfig

func NewAppConfig() *AppConfig

NewAppConfig creates a new AppConfig instance.

func (*AppConfig) Refresh

func (c *AppConfig) Refresh() (flatten.Storage, error)

Refresh refreshes the configuration by merging multiple sources.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL