Parse environment variables to structs in Go. In Go, it’s dead simple to get the value from an environment variable. If you have a type that is not supported out of the box by the lib, you are able to use (or define) and pass custom parsers (and their associated reflect.Type) to the env.ParseWithFuncs() function. Env supports by default anything that implements the TextUnmarshaler interface. That includes things like time.Time for example. The upside is that depending on the format you need, you don't need to change anything. The downside is that if you do need time in another format, you'll need to create your own type. By default, slice types will split the environment value on ,; you can change this behavior by setting the envSeparator tag. If you set the envExpand tag, environment variables (either in ${var} or $var format) in the string will be replaced according with the actual value of the variable.

Features

  • Check the examples in the go doc for more info
  • Pointers, slices and slices of pointers of those types are also supported
  • You can also use/define a custom parser func for any other type you want
  • If you set the envDefault tag for something, this value will be used in the case of absence of it in the environment
  • By default, slice types will split the environment value on ,; you can change this behavior by setting the envSeparator tag
  • Env supports by default anything that implements the TextUnmarshaler interface

Project Samples

Project Activity

See All Activity >

Categories

Libraries

License

MIT License

Follow env

env Web Site

Other Useful Business Software
Easy-to-use online form builder for every business. Icon
Easy-to-use online form builder for every business.

Create online forms and publish them. Get an email for each response. Collect data.

Easy-to-use online form builder for every business. Create online forms and publish them. Get an email for each response. Collect data. Design professional looking forms with JotForm Online Form Builder. Customize with advanced styling options to match your branding. Speed up and simplify your daily work by automating complex tasks with JotForm’s industry leading features. Securely and easily sell products. Collect subscription fees and donations. Being away from your computer shouldn’t stop you from getting the information you need. No matter where you work, JotForm Mobile Forms lets you collect data offline with powerful forms you can manage from your phone or tablet. Get the full power of JotForm at your fingertips. JotForm PDF Editor automatically turns collected form responses into professional, secure PDF documents that you can share with colleagues and customers. Easily generate custom PDF files online!
Learn More
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of env!

Additional Project Details

Operating Systems

Linux, Mac, Windows

Programming Language

Go

Related Categories

Go Libraries

Registered

2023-01-17