Giter VIP home page Giter VIP logo

Comments (1)

ilyakaznacheev avatar ilyakaznacheev commented on July 30, 2024

It is not supported by design, but you can do it now by means of some little tricks.

The library can parse nested structures from environment string variables, but parsing a map of string slices is a tricky one.
The library was designed to parse simple types (not nested), so there is nothing like dynamic parsing (like JSON, etc.), so the library tries to define the type of the variable and then parse the string data into the variable according to the type.

In the case of a map of string slices, there is no way (for now) to specify the string slice with brackets or something, because the library expects to parse either slice (comma-separated list of strings, like a,b,c,d) or map (comma-separated list of colon-separated key-value pairs, like a:b,c:d).

When you want to parse a map of string slices, it is difficult to understand when the slice ends and next key-value pair begins (again, because there are no brackets or something now). But you may do a trick and redefine the map separator with another symbol. The library then will use the symbol to split the map into key-value pairs, and then will try to parse each value into a string slice using a default separator - a comma.

a:x,y;b:v,w

See an example

from cleanenv.

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.