file

package
v0.0.0-...-b9b7e78 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

README

File Source

The file source reads json config from a file

File Format

The expected file format is json

{
    "hosts": {
        "database": {
            "address": "10.0.0.1",
            "port": 3306
        },
        "cache": {
            "address": "10.0.0.2",
            "port": 6379
        }
    }
}

New Source

Specify file source with path to file. Path is optional, it will default to config.json

fileSource := file.NewSource(
	file.WithPath("/tmp/config.json"),
)

Load Source

Load the source into config

// Create new config
conf := config.NewConfig()

// Load file source
conf.Load(fileSource)

Documentation

Overview

Package file is a file source. Expected format is json

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultPath = "config.json"
)

Functions

func NewSource

func NewSource(opts ...source.Option) source.Source

func WithPath

func WithPath(p string) source.Option

WithPath sets the path to file

Types

This section is empty.

Jump to

Keyboard shortcuts

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