]> Cypherpunks.ru repositories - gostls13.git/commitdiff
path: change the output format of ExampleSplit function
authorIrbe Krumina <irbekrm@gmail.com>
Thu, 22 Aug 2019 19:55:30 +0000 (20:55 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Sun, 1 Sep 2019 10:08:36 +0000 (10:08 +0000)
At the moment the last output line of ExampleSplit- two empty strings- are being
trimmed from the output.  I have formatted the output of the function to avoid
whitespace trimming and show empty strings more clearly.

Fixes #23542

Change-Id: Ic2a4d98cfa06db1466c6c6d98099542df9e7c88b
Reviewed-on: https://go-review.googlesource.com/c/go/+/191397
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
src/path/example_test.go

index 315401957a797704ced4279dcf74730a0a3ab42c..67b9718664083b2b0ed51946f12759fb3a01e49a 100644 (file)
@@ -102,11 +102,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: ""
 }