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
a6ebc88b
Commit
a6ebc88b
authored
Dec 16, 2013
by
Robin Eklind
Committed by
Brad Fitzpatrick
Dec 16, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
strings: Add FieldsFunc example.
R=golang-dev, dave CC=golang-dev
https://golang.org/cl/42360043
parent
c184940d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
+9
-0
example_test.go
src/pkg/strings/example_test.go
+9
-0
No files found.
src/pkg/strings/example_test.go
View file @
a6ebc88b
...
...
@@ -7,6 +7,7 @@ package strings_test
import
(
"fmt"
"strings"
"unicode"
)
func
ExampleFields
()
{
...
...
@@ -14,6 +15,14 @@ func ExampleFields() {
// Output: Fields are: ["foo" "bar" "baz"]
}
func
ExampleFieldsFunc
()
{
f
:=
func
(
c
rune
)
bool
{
return
!
unicode
.
IsLetter
(
c
)
&&
!
unicode
.
IsNumber
(
c
)
}
fmt
.
Printf
(
"Fields are: %q"
,
strings
.
FieldsFunc
(
" foo1;bar2,baz3..."
,
f
))
// Output: Fields are: ["foo1" "bar2" "baz3"]
}
func
ExampleContains
()
{
fmt
.
Println
(
strings
.
Contains
(
"seafood"
,
"foo"
))
fmt
.
Println
(
strings
.
Contains
(
"seafood"
,
"bar"
))
...
...
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