You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
460 B
Go
28 lines
460 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"git.awesome-for.me/liuzhiguo/envsubst"
|
|
)
|
|
|
|
func main() {
|
|
stdin := bufio.NewScanner(os.Stdin)
|
|
stdout := bufio.NewWriter(os.Stdout)
|
|
|
|
for stdin.Scan() {
|
|
line, err := envsubst.EvalEnv(stdin.Text())
|
|
if err != nil {
|
|
log.Fatalf("Error while envsubst: %v", err)
|
|
}
|
|
_, err = fmt.Fprintln(stdout, line)
|
|
if err != nil {
|
|
log.Fatalf("Error while writing to stdout: %v", err)
|
|
}
|
|
stdout.Flush()
|
|
}
|
|
}
|