GithubHelp home page GithubHelp logo

config's Introduction

Config wercker status GoDoc

Package config provides convenient access methods to configuration stored as JSON or YAML.

This is a fork of the original version. This version extends the functionality of the original without losing compatibility. Major features added:

Example and more information you can find here.

config's People

Contributors

b4dm4n avatar dlahoza avatar haakonbaa avatar jrdnull avatar madding avatar moraes avatar nikoren avatar olebedev avatar phedoreanu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

config's Issues

Set() does not work

.Set() does not seem to actually work.

cfg.Set("testVal", "test")
x := cfg.UString("testVal", "")
// X is ""!

Godoc examples fail to work on Go 1.9.2

The following YAML file:

development:
  database:
    host: localhost
  users:
    - name: calvin
      password: yukon
    - name: hobbes
      password: tuna
production:
  database:
    host: 192.168.1.1

With the following code:

    if cfg, err := config.ParseYaml("config.yml"); err != nil {
        panic(err)
    } else {
        if testValue, err := cfg.Get("development.database.host"); err != nil {
            panic(err)
        } else {
            fmt.Println("test:", testValue)
        }
    }

Fails with the following error: Invalid type at "development": expected []interface{} or map[string]interface{}; got string

Note that using cfg.Get or cfg.String results in the same error. YAML handling is non-functional with this library as of the latest revision. The code I have used is a slightly modified version of what is demonstrated in package godocs.

need float32

so we dont have Float32 ?
i think its now more commonly used for developing.

yaml key with dots etc

we have a bit more complex yamls.
Please check this snippet:

root: 
  field1: value1
  field.someching.2: value2
  "field number 3": value3

This is valid yaml, but how can I parse it / access second or third value?

Loading the config file into a string

The Documentation ommits how to load the yaml/json file into a string,

Here's how I did it:

    file, readErr := ioutil.ReadFile("config.yaml")
    if readErr != nil {
        fmt.Println("Could not read config.yaml:", readErr)
        // Maybe exit the program?
    }
    yamlConfig := string(file)
        // parse the file etc

This would be useful to include in the docs. Also putting some of the documentation's example code into the README.md would be great.

RenderYaml|Json adding spurious root

If you load a YAML|JSON with the ParsexxxxFile and then re-write a spurious entitiy of 'root' is added to the YAML|JSON.

This means that if you then subsequently reload the saved file it will have the spurious root, and most likely will then add another root which is pretty nasty.

func List()

1st, thx 4 giving the great go lib!
and i have a question in my dev programs:
func List() return a []interface{} for us ,
but how can i use the var(type []interface) as type []string?
hope ur responed

Nested lists

Hi,

What about such a YAML config:

part1:
- level1:
 - level2:
   -level3:
       key1: value1
       key2: value2

How to get deeper nested lists?
cfg.List("part1.0.0.)

does not seem to work.

Lists are lost when using Extend

When extending a config with a second Config object which contains lists, all elements in lists in the second object, except the first element, are lost.

I have narrowed it down to the getKeys function, which generates values like [foo bar 0], [foo bar 1], [foo bar 2], etc : when removing the whole case []interface{}: block in this function, extending seems to work perfectly. I have however not done extensive testing...

Suggestion - List and StringList

Hi,
Would you think a StringList is useful on its own besides List? from my uses, it is very common to have a list of strings in configuration rather than list of interface{}

I'd love to hear your opinion on it
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.