xonfig

package module
v3.0.0-...-3ba9fc9 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: MIT Imports: 4 Imported by: 0

README

xonfig-go v3

Load configuration from XONFIG environment variable. Simple, strict.

Example

package main

import (
	"github.com/gin-gonic/gin"
	"github.com/nixberg/xonfig-go/v3"
)

func main() {
	config := xonfig.MustLoad[struct {
		GinMode         string
		ListenAddress   string
		TrustedPlatform string

		Accounts gin.Accounts
	}]()

	// ...
}

Contents of XONFIG environment variable:

GinMode = "release"
ListenAddress = "0.0.0.0:8080"
TrustedPlatform = "CF-Connecting-IP"

[Accounts]
admin = "8mwf9mrtbu2z2zhbec7qg6kc63"

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingEnv    = errors.New("XONFIG environment variable not present")
	ErrEmptyEnv      = errors.New("XONFIG environment variable contains only white space")
	ErrInvalidConfig = errors.New("invalid config")
)

Functions

func MustLoad

func MustLoad[Config any]() Config

Types

This section is empty.

Jump to

Keyboard shortcuts

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