Permalink
Browse files

Check errors found with errcheck.

  • Loading branch information...
AlekSi committed Mar 2, 2013
1 parent e5b3c85 commit 7b60374c9b119cbb0ab6b9c99300f49a5c21a144
Showing with 8 additions and 8 deletions.
  1. +4 −5 nut/base.go
  2. +2 −1 nut/get.go
  3. +2 −2 nut/main.go
View
@@ -241,13 +241,12 @@ func UnpackNut(fileName string, dir string, removeDir, verbose bool) {
if verbose {
log.Printf("Removing existing directory %s ...", dir)
}
- os.RemoveAll(dir)
+ FatalIfErr(os.RemoveAll(dir))
}
FatalIfErr(os.MkdirAll(dir, WorkspaceDirPerm))
nf := new(NutFile)
- err = nf.ReadFile(fileName)
- FatalIfErr(err)
+ FatalIfErr(nf.ReadFile(fileName))
for _, file := range nf.Reader.File {
if verbose {
@@ -263,8 +262,8 @@ func UnpackNut(fileName string, dir string, removeDir, verbose bool) {
_, err = io.Copy(dst, src)
FatalIfErr(err)
- src.Close()
- dst.Close()
+ FatalIfErr(src.Close())
+ FatalIfErr(dst.Close())
}
}
View
@@ -149,7 +149,8 @@ func runGet(cmd *Command) {
}
nf := new(NutFile)
- nf.ReadFrom(bytes.NewReader(b))
+ _, err = nf.ReadFrom(bytes.NewReader(b))
+ FatalIfErr(err)
deps := NutImports(nf.Imports)
if getV && len(deps) != 0 {
log.Printf("%s depends on nuts: %s", nf.Name, strings.Join(deps, ","))
View
@@ -90,7 +90,7 @@ func help(args ...string) {
func main() {
flag.Usage = func() {
- usageTemplate.Execute(os.Stderr, Commands)
+ FatalIfErr(usageTemplate.Execute(os.Stderr, Commands))
flag.PrintDefaults()
}
@@ -111,7 +111,7 @@ func main() {
cmd.Usage()
os.Exit(2)
}
- cmd.Flag.Parse(args[1:])
+ FatalIfErr(cmd.Flag.Parse(args[1:]))
cmd.Run(cmd)
os.Exit(0)
}

0 comments on commit 7b60374

Please sign in to comment.