Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
f2483c74
Commit
f2483c74
authored
Mar 23, 2011
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gofmt: add profiling flag
R=gri CC=golang-dev
https://golang.org/cl/4295062
parent
b47ec598
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
3 deletions
+27
-3
src/cmd/gofmt/gofmt.go
src/cmd/gofmt/gofmt.go
+27
-3
No files found.
src/cmd/gofmt/gofmt.go
View file @
f2483c74
...
@@ -16,6 +16,7 @@ import (
...
@@ -16,6 +16,7 @@ import (
"io/ioutil"
"io/ioutil"
"os"
"os"
"path/filepath"
"path/filepath"
"runtime/pprof"
"strings"
"strings"
)
)
...
@@ -32,6 +33,9 @@ var (
...
@@ -32,6 +33,9 @@ var (
tabWidth
=
flag
.
Int
(
"tabwidth"
,
8
,
"tab width"
)
tabWidth
=
flag
.
Int
(
"tabwidth"
,
8
,
"tab width"
)
tabIndent
=
flag
.
Bool
(
"tabindent"
,
true
,
"indent with tabs independent of -spaces"
)
tabIndent
=
flag
.
Bool
(
"tabindent"
,
true
,
"indent with tabs independent of -spaces"
)
useSpaces
=
flag
.
Bool
(
"spaces"
,
true
,
"align with spaces instead of tabs"
)
useSpaces
=
flag
.
Bool
(
"spaces"
,
true
,
"align with spaces instead of tabs"
)
// debugging
cpuprofile
=
flag
.
String
(
"cpuprofile"
,
""
,
"write cpu profile to this file"
)
)
)
...
@@ -172,11 +176,33 @@ func walkDir(path string) {
...
@@ -172,11 +176,33 @@ func walkDir(path string) {
func
main
()
{
func
main
()
{
// call gofmtMain in a separate function
// so that it can use defer and have them
// run before the exit.
gofmtMain
()
os
.
Exit
(
exitCode
)
}
func
gofmtMain
()
{
flag
.
Usage
=
usage
flag
.
Usage
=
usage
flag
.
Parse
()
flag
.
Parse
()
if
*
tabWidth
<
0
{
if
*
tabWidth
<
0
{
fmt
.
Fprintf
(
os
.
Stderr
,
"negative tabwidth %d
\n
"
,
*
tabWidth
)
fmt
.
Fprintf
(
os
.
Stderr
,
"negative tabwidth %d
\n
"
,
*
tabWidth
)
os
.
Exit
(
2
)
exitCode
=
2
return
}
if
*
cpuprofile
!=
""
{
f
,
err
:=
os
.
Open
(
*
cpuprofile
,
os
.
O_WRONLY
|
os
.
O_CREATE
|
os
.
O_TRUNC
,
0666
)
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"creating cpu profile: %s
\n
"
,
err
)
exitCode
=
2
return
}
defer
f
.
Close
()
pprof
.
StartCPUProfile
(
f
)
defer
pprof
.
StopCPUProfile
()
}
}
initParserMode
()
initParserMode
()
...
@@ -202,6 +228,4 @@ func main() {
...
@@ -202,6 +228,4 @@ func main() {
walkDir
(
path
)
walkDir
(
path
)
}
}
}
}
os
.
Exit
(
exitCode
)
}
}
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