configo

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

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

Go to latest
Published: Oct 16, 2019 License: MIT Imports: 10 Imported by: 0

README

Configo

Build StatusGo Report Card

A lightweight package to loading config file for golang. (support toml, json, yaml.)

Installation

go get -u github.com/DropFan/configo

Usage

Click here to get examples.

import (
    "github.com/DropFan/configo"
)
var (
    demoConf     *DemoConfigStruct
    configLoader *configo.Loader
)
configLoader, err = configo.NewFromFile(f, demoConf)

Contacts

Author: Tiger(DropFan)

Email: DropFan@Gmail.com

Wechat: DropFan

Telegram: DropFan

https://about.me/DropFan

License

MIT

Documentation

Overview

Package configo : load config struct from toml, json or yaml file. By DropFan <DropFan@Gmail.com> @ 2017/09 version 0.1

Package configo : load config struct from toml, json or yaml file. By DropFan <DropFan@Gmail.com> @ 2017/09 version 0.1

Index

Constants

View Source
const (
	// FileTypeNone : not set
	FileTypeNone = iota
	// FileTypeTOML : toml conf cfg
	FileTypeTOML
	// FileTypeJSON : json
	FileTypeJSON
	// FileTypeYAML : yaml
	FileTypeYAML
)

Variables

This section is empty.

Functions

func ParseFile

func ParseFile(file string, configPtr interface{}) error

ParseFile : parse file to config struct `configPtr` must be a pointer to config struct

Types

type ConfigType

type ConfigType int

ConfigType config file type

type Loader

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

Loader config loader struct

func New

func New(configPtr interface{}) (*Loader, error)

New : Get an instance of config loader. `configPtr` must be a pointer to config struct

func NewFromFile

func NewFromFile(file string, configPtr interface{}) (*Loader, error)

NewFromFile Get an instance of config loader and load config from file. `configPtr` is a pointer to config struct

func (*Loader) GetFile

func (c *Loader) GetFile() string

GetFile return config file path

func (*Loader) LoadFromFile

func (c *Loader) LoadFromFile(f string) error

LoadFromFile load config from Config.FilePath

func (*Loader) LoadFromJSONFile

func (c *Loader) LoadFromJSONFile(f string) error

LoadFromJSONFile load config from json file

func (*Loader) LoadFromToml

func (c *Loader) LoadFromToml(s string) error

LoadFromToml load config from toml string

func (*Loader) LoadFromTomlFile

func (c *Loader) LoadFromTomlFile(f string) error

LoadFromTomlFile load config from toml file

func (*Loader) LoadFromYamlFile

func (c *Loader) LoadFromYamlFile(f string) error

LoadFromYamlFile load config from yaml file

func (*Loader) Reload

func (c *Loader) Reload() error

Reload reload config from config file

func (*Loader) SetFile

func (c *Loader) SetFile(f string) error

SetFile set config filepath and type

func (*Loader) SetFileType

func (c *Loader) SetFileType(t ConfigType)

SetFileType set config file type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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