Giter Club home page Giter Club logo

getenv's Introduction

Hi there ๐Ÿ‘‹

  • I'm currently working on commercial projects at PinUp tech
  • Also, in my free time, I'm developing open-source libraries and tools in GO.
  • I'm learning GCP and Kubernetes.
  • I'm looking for collaboration on interesting Open Source projects written in Golang.
  • Ask me about Golang, Analogue photography, travelling, bicycles, board games, table RPG, miniatures painting.
  • How to reach me: Linkedin Telegram Instagram

halfrost's Github Stats halfrost's Github Trophy

getenv's People

Contributors

dependabot[bot] avatar obalunenko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

getenv's Issues

Thanks & some thoughts (add param, fallback to env, fallback to default)

First of all: thanks! I completely switched to your package as I like it most! I mainly use EnvOrDefault since I always want a fallback default for all possible environment variables.

Sometimes I still am missing the possibillity to handle parameters with this.

I think it would be awesome, if this tool could handle:

  • params
  • env-vars

So the new function would be called: ParamEnvOrDefault and would look something like this:

Example for String:

val := getenv.ParamEnvOrDefault("value", "VALUE", "testString")
fmt.Println(val)

A short form could be (with just two values passed to the function):

val := getenv.ParamEnvOrDefault("VALUE", "testString")
fmt.Println(val)

As "VALUE" (written uppercase) shall be taken as ENV-VAR.
and "value" (written lowercase) shall be taken as parameter.

so getenv.ParamEnvOrDefault("any_VALUE", "testString") can take any value and will automatically transform it to uppercase (for ENV-VAR) and to lowercase (for parameter).

So if I here some examples on how it should work:

Nothing is set (default/fallback will be taken)

$ go run main.go
testString

Just ENV is set - (ENV will be taken)

$ export VALUE=testStringENV
$ go run main.go
testStringENV

ENV & parameter is set - (param will be taken)

$ export VALUE=testStringEnv
$ go run main.go --value=testStringPARAM
testStringPARAM

That would make it very usable outside a docker container (while using docker containers probably everyone uses ENV-VARs only).
But if ou have your compiled main.go as app and store it on your device, you still want to be able to pass parameters to it.

Would be super awesome if you could manage to implement that. This also would not include any breaking changes, as existing code would not be touched.
P.S.: I am open for discussion

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.