diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-01-02 15:05:27 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-01-21 23:53:22 -0800 |
commit | 5a8ea165926cb0737ab03bc48c18dc5198ab5305 (patch) | |
tree | 962dc3357c57f019f85658f99e2e753e30201c27 /libgo/go/path | |
parent | 6ac6529e155c9baa0aaaed7aca06bd38ebda5b43 (diff) | |
download | gcc-5a8ea165926cb0737ab03bc48c18dc5198ab5305.zip gcc-5a8ea165926cb0737ab03bc48c18dc5198ab5305.tar.gz gcc-5a8ea165926cb0737ab03bc48c18dc5198ab5305.tar.bz2 |
libgo: update to Go1.14beta1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/214297
Diffstat (limited to 'libgo/go/path')
-rw-r--r-- | libgo/go/path/example_test.go | 16 | ||||
-rw-r--r-- | libgo/go/path/filepath/path.go | 12 | ||||
-rw-r--r-- | libgo/go/path/filepath/path_unix.go | 2 | ||||
-rw-r--r-- | libgo/go/path/path.go | 8 |
4 files changed, 23 insertions, 15 deletions
diff --git a/libgo/go/path/example_test.go b/libgo/go/path/example_test.go index 77fbfa9..3077729 100644 --- a/libgo/go/path/example_test.go +++ b/libgo/go/path/example_test.go @@ -104,11 +104,15 @@ func ExampleMatch() { } func ExampleSplit() { - fmt.Println(path.Split("static/myfile.css")) - fmt.Println(path.Split("myfile.css")) - fmt.Println(path.Split("")) + split := func(s string) { + dir, file := path.Split(s) + fmt.Printf("path.Split(%q) = dir: %q, file: %q\n", s, dir, file) + } + split("static/myfile.css") + split("myfile.css") + split("") // Output: - // static/ myfile.css - // myfile.css - // + // path.Split("static/myfile.css") = dir: "static/", file: "myfile.css" + // path.Split("myfile.css") = dir: "", file: "myfile.css" + // path.Split("") = dir: "", file: "" } diff --git a/libgo/go/path/filepath/path.go b/libgo/go/path/filepath/path.go index aba1717..26f1833 100644 --- a/libgo/go/path/filepath/path.go +++ b/libgo/go/path/filepath/path.go @@ -201,11 +201,13 @@ func Split(path string) (dir, file string) { return path[:i+1], path[i+1:] } -// Join joins any number of path elements into a single path, adding -// a Separator if necessary. Join calls Clean on the result; in particular, -// all empty strings are ignored. -// On Windows, the result is a UNC path if and only if the first path -// element is a UNC path. +// Join joins any number of path elements into a single path, +// separating them with an OS specific Separator. Empty elements +// are ignored. The result is Cleaned. However, if the argument +// list is empty or all its elements are empty, Join returns +// an empty string. +// On Windows, the result will only be a UNC path if the first +// non-empty element is a UNC path. func Join(elem ...string) string { return join(elem) } diff --git a/libgo/go/path/filepath/path_unix.go b/libgo/go/path/filepath/path_unix.go index fa0e40d..57341ed 100644 --- a/libgo/go/path/filepath/path_unix.go +++ b/libgo/go/path/filepath/path_unix.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix darwin dragonfly freebsd hurd js,wasm linux nacl netbsd openbsd solaris +// +build aix darwin dragonfly freebsd hurd js,wasm linux netbsd openbsd solaris package filepath diff --git a/libgo/go/path/path.go b/libgo/go/path/path.go index 5c90511..c513114 100644 --- a/libgo/go/path/path.go +++ b/libgo/go/path/path.go @@ -149,9 +149,11 @@ func Split(path string) (dir, file string) { return path[:i+1], path[i+1:] } -// Join joins any number of path elements into a single path, adding a -// separating slash if necessary. The result is Cleaned; in particular, -// all empty strings are ignored. +// Join joins any number of path elements into a single path, +// separating them with slashes. Empty elements are ignored. +// The result is Cleaned. However, if the argument list is +// empty or all its elements are empty, Join returns +// an empty string. func Join(elem ...string) string { for i, e := range elem { if e != "" { |