* reload1.c (eliminate_regs_1): Call gen_rtx_raw_SUBREG for SUBREGs
[official-gcc.git] / libgo / go / path / filepath / example_unix_test.go
blobcd8233ceb6a60e2d3f0d55199d0dcb60d7912176
1 // Copyright 2013 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 // +build !windows,!plan9
7 package filepath_test
9 import (
10 "fmt"
11 "path/filepath"
14 func ExampleSplitList() {
15 fmt.Println("On Unix:", filepath.SplitList("/a/b/c:/usr/bin"))
16 // Output:
17 // On Unix: [/a/b/c /usr/bin]
20 func ExampleRel() {
21 paths := []string{
22 "/a/b/c",
23 "/b/c",
24 "./b/c",
26 base := "/a"
28 fmt.Println("On Unix:")
29 for _, p := range paths {
30 rel, err := filepath.Rel(base, p)
31 fmt.Printf("%q: %q %v\n", p, rel, err)
34 // Output:
35 // On Unix:
36 // "/a/b/c": "b/c" <nil>
37 // "/b/c": "../b/c" <nil>
38 // "./b/c": "" Rel: can't make ./b/c relative to /a
41 func ExampleSplit() {
42 paths := []string{
43 "/home/arnie/amelia.jpg",
44 "/mnt/photos/",
45 "rabbit.jpg",
46 "/usr/local//go",
48 fmt.Println("On Unix:")
49 for _, p := range paths {
50 dir, file := filepath.Split(p)
51 fmt.Printf("input: %q\n\tdir: %q\n\tfile: %q\n", p, dir, file)
53 // Output:
54 // On Unix:
55 // input: "/home/arnie/amelia.jpg"
56 // dir: "/home/arnie/"
57 // file: "amelia.jpg"
58 // input: "/mnt/photos/"
59 // dir: "/mnt/photos/"
60 // file: ""
61 // input: "rabbit.jpg"
62 // dir: ""
63 // file: "rabbit.jpg"
64 // input: "/usr/local//go"
65 // dir: "/usr/local//"
66 // file: "go"
69 func ExampleJoin() {
70 fmt.Println("On Unix:")
71 fmt.Println(filepath.Join("a", "b", "c"))
72 fmt.Println(filepath.Join("a", "b/c"))
73 fmt.Println(filepath.Join("a/b", "c"))
74 fmt.Println(filepath.Join("a/b", "/c"))
75 // Output:
76 // On Unix:
77 // a/b/c
78 // a/b/c
79 // a/b/c
80 // a/b/c