2015-10-29 Steven G. Kargl <kargl@gcc.gnu.org>
[official-gcc.git] / libgo / go / path / example_test.go
blobca18b32305e68a8223977aafc99e0742d455c222
1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 package path
7 /* Commented out until gccgo has example support.
9 import (
10 "fmt"
11 "path"
14 func ExampleBase() {
15 fmt.Println(path.Base("/a/b"))
16 // Output: b
19 func ExampleClean() {
20 paths := []string{
21 "a/c",
22 "a//c",
23 "a/c/.",
24 "a/c/b/..",
25 "/../a/c",
26 "/../a/b/../././/c",
29 for _, p := range paths {
30 fmt.Printf("Clean(%q) = %q\n", p, path.Clean(p))
33 // Output:
34 // Clean("a/c") = "a/c"
35 // Clean("a//c") = "a/c"
36 // Clean("a/c/.") = "a/c"
37 // Clean("a/c/b/..") = "a/c"
38 // Clean("/../a/c") = "/a/c"
39 // Clean("/../a/b/../././/c") = "/a/c"
42 func ExampleDir() {
43 fmt.Println(path.Dir("/a/b/c"))
44 // Output: /a/b
47 func ExampleExt() {
48 fmt.Println(path.Ext("/a/b/c/bar.css"))
49 // Output: .css
52 func ExampleIsAbs() {
53 fmt.Println(path.IsAbs("/dev/null"))
54 // Output: true
57 func ExampleJoin() {
58 fmt.Println(path.Join("a", "b", "c"))
59 // Output: a/b/c
62 func ExampleSplit() {
63 fmt.Println(path.Split("static/myfile.css"))
64 // Output: static/ myfile.css