Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 767 Bytes

README.md

File metadata and controls

26 lines (20 loc) · 767 Bytes

Golang Environment Variables Go Reference

A small Golang package for parsing values from environment variables based on github.com/spf13/cast.

Usage

This package was originally written for use in simple AWS Lambda functions to reduce boilerplate, ex:

package main

import (
    "fmt"
    "context"

    "github.com/aws/aws-lambda-go/lambda"
    "github.com/bored-engineer/env"
)

var FunctionName = env.String("AWS_LAMBDA_FUNCTION_NAME")

func invoke(ctx context.Context) {
    fmt.Printf("Hello from %s", FunctionName)
}

func main() {
    lambda.Start(invoke)
}