diff options
| author | Russ Cox <rsc@golang.org> | 2016-03-14 20:23:22 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2016-04-03 16:55:51 +0000 |
| commit | 1f7e55e418659dc3b5fe66792b85807a7065144f (patch) | |
| tree | 016dbff6c4e44f99de5b5306c92ba56e48306666 /src/path/filepath | |
| parent | 29a6149e67a9c382938ffb40102fb989a0a6db48 (diff) | |
| download | go-1f7e55e418659dc3b5fe66792b85807a7065144f.tar.xz | |
path, path/filepath: add Join example with joined rooted path
This makes clear that Go's path.Join and filepath.Join are different
from the Python os.path.join (and perhaps others).
Requested in private mail.
Change-Id: Ie5dfad8a57f9baa5cca31246af1fd4dd5b1a64ee
Reviewed-on: https://go-review.googlesource.com/20711
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/path/filepath')
| -rw-r--r-- | src/path/filepath/example_unix_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/path/filepath/example_unix_test.go b/src/path/filepath/example_unix_test.go index 893be1b198..cd8233ceb6 100644 --- a/src/path/filepath/example_unix_test.go +++ b/src/path/filepath/example_unix_test.go @@ -65,3 +65,17 @@ func ExampleSplit() { // dir: "/usr/local//" // file: "go" } + +func ExampleJoin() { + fmt.Println("On Unix:") + fmt.Println(filepath.Join("a", "b", "c")) + fmt.Println(filepath.Join("a", "b/c")) + fmt.Println(filepath.Join("a/b", "c")) + fmt.Println(filepath.Join("a/b", "/c")) + // Output: + // On Unix: + // a/b/c + // a/b/c + // a/b/c + // a/b/c +} |
