Skip to content

pazams/envexpand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

envexpand

Expand environment variables in strings

Example

package main

import (
	"fmt"
	"github.com/pazams/envexpand"
	"os"
)

func main() {
	os.Setenv("ENVEXPAND_TEST", "google.com")
	defer os.Unsetenv("ENVEXPAND_TEST")

	input := "http://${ENVEXPAND_TEST}"
	output := envexpand.ExpandString(input)

	fmt.Println("input:", input)
	fmt.Println("ouput:", output)
}

License

This package takes a few lines and inspiration from golang's regexp package source, namely from func (re *Regexp) expand(dst []byte, template string, bsrc []byte, src string, match []int) []byte.

The use of BSD-3 license follows from that.

About

Expand environment variables in strings

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages