esub

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 4 Imported by: 1

README

esub

A library to replace string placeholders with environment variables.

Usage

package main

import (
	"fmt"
	"os"

	"github.com/winebarrel/esub"
)

func main() {
	os.Setenv("foo", "ZOO")
	os.Setenv("BAR", "baz")
	tmpl := "foo:${foo} BAR:${BAR}"
	out, err := esub.Fill(tmpl)
	if err != nil {
		panic(err)
	}
	fmt.Println(out) //=> "foo:ZOO BAR:baz"
}
Escape Placeholders
tmpl := "foo:$${foo} BAR:${BAR}"
//           ^^^
out, _ := esub.Fill(tmpl)
fmt.Println(out) //=> "foo:${foo} BAR:baz"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Eval

func Eval(tmpl string, envList []string) (string, error)

func Fill

func Fill(tmpl string) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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