aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/os/example_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/os/example_test.go')
-rw-r--r--libgo/go/os/example_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/libgo/go/os/example_test.go b/libgo/go/os/example_test.go
index 5749194..e21415a 100644
--- a/libgo/go/os/example_test.go
+++ b/libgo/go/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}."))