configure

package module
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

README

configure

Help configure go projects using both a configuration template yaml file and environment variables.

Usage

Import the package and load a YAML file with template data. If your current directory contains a .env file, this will be loaded automatically.

package main

import (
    "log"
    "os"

    "github.com/invopop/configure"
)

const configFile = "samples/config.yaml.tmpl"

// Config definition for our project
type Config struct {
    S3Bucket string `json:"s3_bucket"`
}

func main() {
    conf := new(Config)
    if err := configure.Load(configFile, conf); err != nil {
        log.Fatal("Error loading configuration file")
    }

    fmt.Printf("S3 Bucket is: %v\n", conf.S3Bucket)
}

Documentation

Overview

Package configure makes it easier to load configuration files from YAML documents and will handle environment variable substitution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(file string, conf interface{}) error

Load reads in the configuration file relative to the current path. Data is expected in YAML format with Golang template definitions.

Types

This section is empty.

Directories

Path Synopsis
pkg
grpcconf
Package grpcconf helps configure gRPC service connections.
Package grpcconf helps configure gRPC service connections.
natsconf
Package natsconf helps configure NATS connections from a JSON/YAML configuration source.
Package natsconf helps configure NATS connections from a JSON/YAML configuration source.
zeroconf
Package zeroconf helps configure the zerolog package using a json configuration.
Package zeroconf helps configure the zerolog package using a json configuration.

Jump to

Keyboard shortcuts

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