diff --git a/src/path/example_test.go b/src/path/example_test.go index fa8c28d2e1..e8d684f771 100644 --- a/src/path/example_test.go +++ b/src/path/example_test.go @@ -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() { 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 +}