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
0444d697
Commit
0444d697
authored
Nov 21, 2008
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
automatically add tabs after newlines
R=gri DELTA=12 (10 added, 0 deleted, 2 changed) OCL=19758 CL=19758
parent
01b44bbf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
testing.go
src/lib/testing.go
+12
-2
No files found.
src/lib/testing.go
View file @
0444d697
...
...
@@ -14,6 +14,16 @@ func init() {
flag
.
Bool
(
"chatty"
,
false
,
&
chatty
,
"chatty"
);
}
// Insert tabs after newlines - but not the last one
func
Tabify
(
s
string
)
string
{
for
i
:=
0
;
i
<
len
(
s
)
-
1
;
i
++
{
// -1 because if last char is newline, don't bother
if
s
[
i
]
==
'\n'
{
return
s
[
0
:
i
+
1
]
+
"
\t
"
+
Tabify
(
s
[
i
+
1
:
len
(
s
)]);
}
}
return
s
}
export
type
T
struct
{
errors
string
;
failed
bool
;
...
...
@@ -31,11 +41,11 @@ func (t *T) FailNow() {
}
func
(
t
*
T
)
Log
(
args
...
)
{
t
.
errors
+=
"
\t
"
+
fmt
.
sprintln
(
args
);
t
.
errors
+=
"
\t
"
+
Tabify
(
fmt
.
sprintln
(
args
)
);
}
func
(
t
*
T
)
Logf
(
format
string
,
args
...
)
{
t
.
errors
+=
fmt
.
sprintf
(
"
\t
"
+
format
,
args
);
t
.
errors
+=
Tabify
(
fmt
.
sprintf
(
"
\t
"
+
format
,
args
)
);
l
:=
len
(
t
.
errors
);
if
l
>
0
&&
t
.
errors
[
l
-
1
]
!=
'\n'
{
t
.
errors
+=
"
\n
"
...
...
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