Commit 1f7e55e4 authored by Russ Cox's avatar Russ Cox

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/20711Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 29a6149e
......@@ -54,7 +54,14 @@ func ExampleIsAbs() {
func ExampleJoin() {
fmt.Println(path.Join("a", "b", "c"))
// Output: a/b/c
fmt.Println(path.Join("a", "b/c"))
fmt.Println(path.Join("a/b", "c"))
fmt.Println(path.Join("a/b", "/c"))
// Output:
// a/b/c
// a/b/c
// a/b/c
// a/b/c
}
func ExampleSplit() {
......
......@@ -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
}
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