skprconfig

package module
v0.0.0-...-ef4cd80 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: GPL-2.0 Imports: 5 Imported by: 2

README

skprconfig

CircleCI

This is a go package providing an interface to read config values on the skpr.io platform.

Usage

import "github.com/skpr/skprconfig"

// Load the config.
config, err := skprconfig.Load()
if err != nil {
  panic("failed to load config")
}

// Get a string value.
bar, ok := config.Get("token")
if !ok {
  panic("token config key not found")
}

// Get the configured value for "port", with a default fallback if missing.
listenPort := config.GetWithFallback("port", "8888")

Documentation

Index

Constants

View Source
const (
	// DefaultPath is the default file path used to mount config.
	DefaultPath string = "/etc/skpr/data/config.json"
)

Variables

View Source
var (
	// ErrNotFound is returned when Skpr configuration cannot be found.
	ErrNotFound = errors.New("configuration not found")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config represents the config.

func Load

func Load(options ...func(config *Config)) (*Config, error)

Load loads Config from file.

func (*Config) Get

func (c *Config) Get(key string) (string, bool)

Get returns a string value for the key.

func (*Config) GetWithFallback

func (c *Config) GetWithFallback(key, fallback string) string

GetWithFallback returns the configured value of a given key, and the fallback value if no key does not exist.

Jump to

Keyboard shortcuts

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