Skip to content

A simple configuration library that supports multiple files and formats.

License

Notifications You must be signed in to change notification settings

goschtalt/goschtalt

Folders and files

NameName
Last commit message
Last commit date
Apr 28, 2025
Nov 19, 2022
Mar 4, 2023
Jan 24, 2025
Jan 23, 2025
Nov 19, 2022
May 19, 2023
Aug 21, 2022
Jul 30, 2022
Aug 2, 2022
Jul 30, 2022
Jan 24, 2025
Mar 6, 2024
Dec 21, 2022
Dec 21, 2022
Nov 30, 2023
May 31, 2023
Nov 18, 2022
Apr 12, 2024
Apr 12, 2024
May 30, 2023
May 30, 2023
Apr 6, 2024
Jan 7, 2024
Dec 21, 2022
Jan 23, 2025
Jan 23, 2025
Apr 12, 2024
Nov 30, 2023
Jan 23, 2025
Nov 30, 2023
Aug 1, 2023
Aug 1, 2023
Apr 12, 2024
May 13, 2023
Aug 1, 2023
Apr 6, 2024
May 13, 2023
Apr 8, 2023
Nov 2, 2022
Apr 12, 2024
Jan 23, 2025
Sep 15, 2023
May 1, 2023
Mar 5, 2023
May 31, 2023
Jan 23, 2025

Repository files navigation

goschtalt

Build Status codecov Go Report Card GitHub Release GoDoc

A customizable configuration library that supports multiple files and formats.

Goals & Themes

  • Make support for multiple configuration files and sources easy to use and extend.
  • Simplify tracing the origin of a configuration value.
  • Favor user customization options over building everything in, keeping dependencies to a minimum.
  • Embrace patterns that make using other powerful libraries (kong, fx, etc) simple.

API Stability

This package has not yet released to 1.x yet, so APIs are subject to change for a bit longer.

After v1 is released, SemVer will be followed.

Installation

go get github.com/goschtalt/goschtalt

Extensions

Instead of trying to build everything in, goschtalt tries to only build in what is absolutely necessary and favor extensions. This enables a diversity of ecosystem while not bloating your code with a bunch of dependencies.

The following are popular goschtalt extensions:

Examples

Coming soon.

Dependencies

There are only one production dependencies in the core goschtalt code beyond the go standard library. The rest are testing dependencies.

Production dependencies:

Compilation of a Configuration

This is more detailed overview of how the configuration is compiled.

Loading
stateDiagram-v2
    direction TB

    state Gather_Inputs {
        direction TB
        AddBuffer() --> New()
        AddFile() --> New()
        AddValue(AsDefault()) --> New()
    }

    state Sequence {
        direction TB
        Defaults:Defaults by order added.
        Records:Records sorted using record label.
        ex:Expand instructions by order added.

        Defaults --> Records
        Records --> ex
    }

    state Compile {
        calc:Calculate configuration<br/>tree at this point.
        eval:Apply all Expand()<br/>and ExpandEnv()<br/>to configuration<br/>tree in order.
        fetch:Call any user<br/>provided funcs with<br/>configuration tree.
        next:Next<br/>Configuration<br/>Tree Part
        merge:Merge the new<br/>configuration tree part<br/>with the current tree
        Empty:Empty<br/>Configuration<br/>Tree


        Empty --> calc
        calc --> eval:If a user func<br/>is provided
        calc --> next:If no user func<br/>is provided
        eval --> fetch
        fetch --> next
        next --> merge
        merge --> calc
    }

    state Expand {
        exp:Apply all Expand()<br/>and ExpandEnv()<br/>to configuration<br/>tree in order.
    }

    state Active {
        active:Active Configuration
        unmarshal:Unmarshal()
        active --> unmarshal
        unmarshal --> active
    }
    New() --> Sequence
    Sequence --> Compile
    Compile --> Expand
    Expand --> Active
    Active --> Sequence:With() or Compile() called<br/>resequences the lists and<br/>recalculates the <br/>configuration tree.