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
5f2ecbff
Commit
5f2ecbff
authored
Feb 21, 2012
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
text/tabwriter: fix documentation by adding an example.
R=rsc, r CC=golang-dev
https://golang.org/cl/5685069
parent
5ba08f42
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
6 deletions
+38
-6
example_test.go
src/pkg/text/tabwriter/example_test.go
+38
-0
tabwriter.go
src/pkg/text/tabwriter/tabwriter.go
+0
-6
No files found.
src/pkg/text/tabwriter/example_test.go
0 → 100644
View file @
5f2ecbff
// 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
tabwriter_test
import
(
"fmt"
"os"
"text/tabwriter"
)
func
ExampleWriter_Init
()
{
w
:=
new
(
tabwriter
.
Writer
)
// Format in tab-separated columns with a tab stop of 8.
w
.
Init
(
os
.
Stdout
,
0
,
8
,
0
,
'\t'
,
0
)
fmt
.
Fprintln
(
w
,
"a
\t
b
\t
c
\t
d
\t
."
)
fmt
.
Fprintln
(
w
,
"123
\t
12345
\t
1234567
\t
123456789
\t
."
)
fmt
.
Fprintln
(
w
)
w
.
Flush
()
// Format right-aligned in space-separated columns of minimal width 5
// and at least one blank of padding (so wider column entries do not
// touch each other).
w
.
Init
(
os
.
Stdout
,
5
,
0
,
1
,
' '
,
tabwriter
.
AlignRight
)
fmt
.
Fprintln
(
w
,
"a
\t
b
\t
c
\t
d
\t
."
)
fmt
.
Fprintln
(
w
,
"123
\t
12345
\t
1234567
\t
123456789
\t
."
)
fmt
.
Fprintln
(
w
)
w
.
Flush
()
// output:
// a b c d .
// 123 12345 1234567 123456789 .
//
// a b c d.
// 123 12345 1234567 123456789.
}
src/pkg/text/tabwriter/tabwriter.go
View file @
5f2ecbff
...
...
@@ -169,12 +169,6 @@ const (
// to the tab width in the viewer displaying the result)
// flags formatting control
//
// To format in tab-separated columns with a tab stop of 8:
// b.Init(w, 8, 1, 8, '\t', 0);
//
// To format in space-separated columns with at least 4 spaces between columns:
// b.Init(w, 0, 4, 8, ' ', 0);
//
func
(
b
*
Writer
)
Init
(
output
io
.
Writer
,
minwidth
,
tabwidth
,
padding
int
,
padchar
byte
,
flags
uint
)
*
Writer
{
if
minwidth
<
0
||
tabwidth
<
0
||
padding
<
0
{
panic
(
"negative minwidth, tabwidth, or padding"
)
...
...
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