summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/os/example_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/os/example_test.go b/src/os/example_test.go
index 5749194871..e21415a3fd 100644
--- a/src/os/example_test.go
+++ b/src/os/example_test.go
@@ -82,6 +82,24 @@ func init() {
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() {
fmt.Println(os.ExpandEnv("$USER lives in ${HOME}."))