зеркало из https://github.com/CryptoPro/go.git
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>
This commit is contained in:
Родитель
29a6149e67
Коммит
1f7e55e418
|
@ -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
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче