Skip to content

na4ma4/config

Repository files navigation

na4ma4/config

CI GoDoc

Go package for a thread-safe config interface

Installation

go get -u github.com/na4ma4/config

Example

package main

import (
    "fmt"
    "log"

    "github.com/na4ma4/config"
)

func main() {
    // Create config (example supplied viper)
    // Supplied ViperConf takes a project name, then a list of file names,
    // if no filenames are found, the last one is considered where you want the config to be saved.
    vcfg := config.NewViperConfig("test-project2", "artifacts/test-project.toml", "/tmp/test-project.toml", "test/test-project.toml")

    server := vcfg.GetString("server.address")

    fmt.Printf("Server: %s\n", server)

    err := vcfg.Save()
    if err != nil {
        log.Fatal(err)
    }
}