Commit ef993816 authored by azat's avatar azat Committed by Brad Fitzpatrick

os: Add example for Expand function.

Change-Id: I581492c29158e57ca2f98b75f47870791965a7ff
Reviewed-on: https://go-review.googlesource.com/81155Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 67fe8b56
...@@ -82,6 +82,24 @@ func init() { ...@@ -82,6 +82,24 @@ func init() {
os.Unsetenv("GOPATH") os.Unsetenv("GOPATH")
} }
func ExampleExpand() {
mapper := func(placeholderName string) string {
switch placeholderName {
case "DAY_PART":
return "morning"
case "USER":
return "Gopher"
}
return ""
}
fmt.Println(os.Expand("Good ${DAY_PART}, $USER!", mapper))
// Output:
// Good morning, Gopher!
}
func ExampleExpandEnv() { func ExampleExpandEnv() {
fmt.Println(os.ExpandEnv("$USER lives in ${HOME}.")) fmt.Println(os.ExpandEnv("$USER lives in ${HOME}."))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment