Skip to content
/ owl Public

Go yaml configuration lib,can get config value from yaml file or etcd cluster like viper lib.

License

Notifications You must be signed in to change notification settings

gsxhnd/owl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoDoc license Test codecov Go Report Card Release GitHub release (latest by date) Alt

owl

Go yaml configuration lib,can get config value from yaml file or etcd cluster like viper lib.

Owl also support binary cli, help you store yaml file's content into etcd cluster.

1. Install as cli

# macos
wget https://github.com/gsxhnd/owl/releases/latest/download/owl-darwin-amd64 -O owl
# linux x64
wget https://github.com/gsxhnd/owl/releases/latest/download/owl-linux-amd64 -O owl
# windows x64
wget https://github.com/gsxhnd/owl/releases/latest/download/owl-windows-amd64.exe -O owl.exe

chmod +x /usr/local/bin/owl

## show version
owl version

owl version:  1.5.1
owl commit:  6840df54b9a566acb78b36195fd9e826bb04d6cf
owl tree state:  clean
owl build date:  2020-12-29T15:49:14+0800
go version:  go1.15.6
go compiler:  gc
platform:  darwin/amd64

1.1 CLI Usage

NAME:
   owl - owl

USAGE:
   owl [global options] command [command options] [arguments...]

COMMANDS:
   get       get value by key
   get_keys  get keys by prefix
   put       read file then put value to etcd
   delete    delete value by key
   version   show version
   help, h   Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --endpoint value, -e value  (default: "http://127.0.0.1:2379")
   --help, -h                  show help (default: false)

2. Add as lib

go get -u github.com/gsxhnd/owl

Putting Values into owl

Reading Config Files

Owl requires minimal configuration so it knows where to look for config files. Owl just supports YAML file.

Examples:

owl.SetConfName("test.yaml")
owl.AddConfPath("./mock/")
err := owl.ReadConf()
if err != nil { // Handle errors reading the config file
  panic(fmt.Errorf("Fatal error config file: %s \n", err))
}

Getting Values From

In owl, there are a few ways to get a value depending on the value’s type. The following functions and methods exist:

  • Get(key string) : interface{}
  • GetBool(key string) : bool
  • GetFloat64(key string) : float64
  • GetInt(key string) : int
  • GetIntSlice(key string) : []int
  • GetString(key string) : string
  • GetStringMap(key string) : map[string]interface{}
  • GetStringMapString(key string) : map[string]string
  • GetStringSlice(key string) : []string
  • GetAll() : map[string]interface{}

About

Go yaml configuration lib,can get config value from yaml file or etcd cluster like viper lib.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published