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
56452c53
Commit
56452c53
authored
Dec 14, 2010
by
Christopher Wedgwood
Committed by
Rob Pike
Dec 14, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
govet: on error continue to the next file
R=r, rsc CC=golang-dev
https://golang.org/cl/3578041
parent
9f6de01d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
govet.go
src/cmd/govet/govet.go
+17
-8
No files found.
src/cmd/govet/govet.go
View file @
56452c53
...
...
@@ -23,6 +23,14 @@ var verbose = flag.Bool("v", false, "verbose")
var
printfuncs
=
flag
.
String
(
"printfuncs"
,
""
,
"comma-separated list of print function names to check"
)
var
exitCode
=
0
// setExit sets the value for os.Exit when it is called, later. It
// remembers the highest value.
func
setExit
(
err
int
)
{
if
err
>
exitCode
{
exitCode
=
err
}
}
// Usage is a replacement usage function for the flags package.
func
Usage
()
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Usage of %s:
\n
"
,
os
.
Args
[
0
])
...
...
@@ -50,7 +58,7 @@ func main() {
var
err
os
.
Error
skip
,
err
=
strconv
.
Atoi
(
name
[
colon
+
1
:
])
if
err
!=
nil
{
die
(
`illegal format for "Func:N" argument %q; %s`
,
name
,
err
)
error
(
`illegal format for "Func:N" argument %q; %s`
,
name
,
err
)
}
name
=
name
[
:
colon
]
}
...
...
@@ -79,17 +87,18 @@ func doFile(name string, reader io.Reader) {
fs
:=
token
.
NewFileSet
()
parsedFile
,
err
:=
parser
.
ParseFile
(
fs
,
name
,
reader
,
0
)
if
err
!=
nil
{
die
(
"%s: %s"
,
name
,
err
)
error
(
"%s: %s"
,
name
,
err
)
return
}
file
:=
&
File
{
fs
.
File
(
parsedFile
.
Pos
())}
file
.
checkFile
(
name
,
parsedFile
)
}
//
die formats the error to standard error, adding program identification
//
and a newline, and exits the program.
func
die
(
format
string
,
args
...
interface
{})
{
//
error formats the error to standard error, adding program
//
identification and a newline
func
error
(
format
string
,
args
...
interface
{})
{
fmt
.
Fprintf
(
os
.
Stderr
,
"govet: "
+
format
+
"
\n
"
,
args
...
)
os
.
Exit
(
2
)
set
Exit
(
2
)
}
// Println is fmt.Println guarded by -v.
...
...
@@ -111,13 +120,13 @@ func Printf(format string, args ...interface{}) {
// Bad reports an error and sets the exit code..
func
(
f
*
File
)
Bad
(
pos
token
.
Pos
,
args
...
interface
{})
{
f
.
Warn
(
pos
,
args
...
)
exitCode
=
1
setExit
(
1
)
}
// Badf reports a formatted error and sets the exit code.
func
(
f
*
File
)
Badf
(
pos
token
.
Pos
,
format
string
,
args
...
interface
{})
{
f
.
Warnf
(
pos
,
format
,
args
...
)
exitCode
=
1
setExit
(
1
)
}
// Warn reports an error but does not set the exit code.
...
...
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