Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
0d8c6b4f
Commit
0d8c6b4f
authored
Jan 19, 2012
by
Sanjay Menakuru
Committed by
Andrew Gerrand
Jan 19, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
path: added examples
R=rsc, adg CC=golang-dev
https://golang.org/cl/5503089
parent
af08cfa4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
+61
-0
example_test.go
src/pkg/path/example_test.go
+61
-0
No files found.
src/pkg/path/example_test.go
0 → 100644
View file @
0d8c6b4f
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
path_test
import
(
"fmt"
"path"
)
// b
func
ExampleBase
()
{
fmt
.
Println
(
path
.
Base
(
"/a/b"
))
}
// Clean("a/c") = "a/c"
// Clean("a//c") = "a/c"
// Clean("a/c/.") = "a/c"
// Clean("a/c/b/..") = "a/c"
// Clean("/../a/c") = "/a/c"
// Clean("/../a/b/../././/c") = "/a/c"
func
ExampleClean
()
{
paths
:=
[]
string
{
"a/c"
,
"a//c"
,
"a/c/."
,
"a/c/b/.."
,
"/../a/c"
,
"/../a/b/../././/c"
,
}
for
_
,
p
:=
range
paths
{
fmt
.
Printf
(
"Clean(%q) = %q
\n
"
,
p
,
path
.
Clean
(
p
))
}
}
// /a/b
func
ExampleDir
()
{
fmt
.
Println
(
path
.
Dir
(
"/a/b/c"
))
}
// .css
func
ExampleExt
()
{
fmt
.
Println
(
path
.
Ext
(
"/a/b/c/bar.css"
))
}
// true
func
ExampleIsAbs
()
{
fmt
.
Println
(
path
.
IsAbs
(
"/dev/null"
))
}
// a/b/c
func
ExampleJoin
()
{
fmt
.
Println
(
path
.
Join
(
"a"
,
"b"
,
"c"
))
}
// static/ myfile.css
func
ExampleSplit
()
{
fmt
.
Println
(
path
.
Split
(
"static/myfile.css"
))
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment