library: os.Expand

This commit is contained in:
xushiwei
2024-07-29 11:06:33 +08:00
parent 8b6b039c13
commit cbd891785e
2 changed files with 20 additions and 2 deletions

View File

@@ -0,0 +1,20 @@
package main
import (
"fmt"
"os"
)
func main() {
mapper := func(placeholderName string) string {
switch placeholderName {
case "DAY_PART":
return "morning"
case "NAME":
return "Gopher"
}
return ""
}
fmt.Println(os.Expand("Good ${DAY_PART}, $NAME!", mapper))
}