Add support for -std=c++2a.
[official-gcc.git] / libgo / go / path / example_test.go
blob21ed1fb2fcd430a3f36538e3c6c8d356725b5bb1
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 fmt.Println(path.Base("/"))
17 fmt.Println(path.Base(""))
18 // Output:
19 // b
20 // /
21 // .
24 func ExampleClean() {
25 paths := []string{
26 "a/c",
27 "a//c",
28 "a/c/.",
29 "a/c/b/..",
30 "/../a/c",
31 "/../a/b/../././/c",
32 "",
35 for _, p := range paths {
36 fmt.Printf("Clean(%q) = %q\n", p, path.Clean(p))
39 // Output:
40 // Clean("a/c") = "a/c"
41 // Clean("a//c") = "a/c"
42 // Clean("a/c/.") = "a/c"
43 // Clean("a/c/b/..") = "a/c"
44 // Clean("/../a/c") = "/a/c"
45 // Clean("/../a/b/../././/c") = "/a/c"
46 // Clean("") = "."
49 func ExampleDir() {
50 fmt.Println(path.Dir("/a/b/c"))
51 fmt.Println(path.Dir("a/b/c"))
52 fmt.Println(path.Dir("/"))
53 fmt.Println(path.Dir(""))
54 // Output:
55 // /a/b
56 // a/b
57 // /
58 // .
61 func ExampleExt() {
62 fmt.Println(path.Ext("/a/b/c/bar.css"))
63 fmt.Println(path.Ext("/"))
64 fmt.Println(path.Ext(""))
65 // Output:
66 // .css
71 func ExampleIsAbs() {
72 fmt.Println(path.IsAbs("/dev/null"))
73 // Output: true
76 func ExampleJoin() {
77 fmt.Println(path.Join("a", "b", "c"))
78 fmt.Println(path.Join("a", "b/c"))
79 fmt.Println(path.Join("a/b", "c"))
80 fmt.Println(path.Join("", ""))
81 fmt.Println(path.Join("a", ""))
82 fmt.Println(path.Join("", "a"))
83 // Output:
84 // a/b/c
85 // a/b/c
86 // a/b/c
88 // a
89 // a
92 func ExampleSplit() {
93 fmt.Println(path.Split("static/myfile.css"))
94 fmt.Println(path.Split("myfile.css"))
95 fmt.Println(path.Split(""))
96 // Output:
97 // static/ myfile.css
98 // myfile.css