GithubHelp home page GithubHelp logo

jxsl13 / simple-configo Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 259 KB

Streamline the parsing of config files (especially .env files) with the implementation of a single interface method.

License: MIT License

Go 100.00%
config configuration environment-variables go golang

simple-configo's People

Contributors

jxsl13 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

simple-configo's Issues

File parser

  • Load file content to string
  • Load json file content to interface
  • Load yaml file content into struct

Allow Option to set a mutex(sync.Locker)

A mutex may be locked before the PreParseAction, during the ParseFunction until after the PostParseAction

That same mutex may also be locked for the unparsing process where values are serialized back into a string map.

The sync.Locker is to be used and in case of nil nothing is locked.

Introduce Action func() error

In order to remove the parameter IsPseudoOption
wich is basically an option that executes the ParserFunction butbdoes not evaluate the default value nor does it use the value passed tobthe ParseFunc thus making the string value argument of the ParseFunc obsolete.

The next refactoring should remove IsPseudoOption and introduce multiple action parameters.
An Action ActionFunc is a function that does not take any arguments but returns an error.

We want a PreParseAction, a PostParseAction and a PreUnparseAction.

An option not containing a ParseFunction nor an UnparseFunction and at least one Action function is called an action.

An option struct containing either of ParseFunction or UnparseFunction of both is called an option.
These are explicitly associated with a config variable in your config struct.

Actions may also be associated with a config variable but they do not parse the key value env map provided at the time of parsing a configiration.

Config serialization interface

You might want to have configuration parameters saved back into a file once your application closes, thus it might make sense to introduce a secondary ParseFunc which has the same signature as the ParseFunc but is explicitly a

  • SaveFunc
defer configo.Save(cfg)

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.