envs

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2021 License: MIT Imports: 6 Imported by: 0

README

envs

Very simple library for setting values associated with environment variables.

Usage

Here's a simple example

package main

import(
  "github.com/ThreadedStream/envs"
  "fmt"
)

type Config struct{
  Host   string `env:"HOST"    fallback:"127.0.0.1"`
  Port   int    `env:"PORT"    fallback:"3000"`
  UseSSL bool   `env:"USE_SSL" fallback:"true"`
}

func main() { 
  var(
    c = &Config{}
    err = envs.Parse(c)
  )
  
  if err != nil{
    panic(err)
  }
  
  fmt.Printf("Host: %s, Port: %d, UseSSL: %t", c.Host, c.Port, c.UseSSL)
  
  // Host: 127.0.0.1, Port: 3000, UseSSL: true 
}

TODOs

[] Add more tests

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(value interface{}) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL