Giter VIP home page Giter VIP logo

Comments (8)

MostHated avatar MostHated commented on May 14, 2024 1

Well, that was part of the issue. I was not sure how to get the [section] as a variable using this package. The way I ended up doing it was rclone was reading their config using the goconfig package which had a function called GetSectionList() which would return a list of each of the [sections] values as string, then using that list of sections I could use GetSection() which returned a map[string]string of each key/value within the [section], so then I just stored those within a struct.

It would be much cleaner/nicer to use this package as I could directly get config.String(section.type) (or client_id, etc) but I was not sure how to get the actual [section] data as a variable.

from config.

inhere avatar inhere commented on May 14, 2024

Oo, why use this?

from config.

MostHated avatar MostHated commented on May 14, 2024

Well, I was going to use it to parse the config file for RClone backup tool's config data, but instead I just ended up looking through their code to see how they were getting the data themselves and did it using the same method they did. I don't really like the method as much, but it worked, so it's ok, no need for this question anymore.

from config.

inhere avatar inhere commented on May 14, 2024

If you know the variable name when you use it. Can be taken directly like this:

Remote.Type = config.String("VARNAME.type")
Remote.ClientId = config.String("VARNAME.client_id")
...

from config.

inhere avatar inhere commented on May 14, 2024

OO, Very sorry this library can not meet your needs.

from config.

MostHated avatar MostHated commented on May 14, 2024

No worries at all. I use this for several other projects and it works awesome. :D 👍

from config.

inhere avatar inhere commented on May 14, 2024

Thanks you.
If you just want to use INI for simple config management, You can look at my another library https://github.com/gookit/ini

// get all section names
names := ini.SectionKeys(false)

from config.

MostHated avatar MostHated commented on May 14, 2024

Oh, interesting, that might do just what I need then. I will have to try it out. Thanks. 👍

from config.

Related Issues (20)

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.