Browse files

cut back on fmt.Sprintf calls

  • Loading branch information...
1 parent 10409a5 commit 7de62999c5f10304d16876a0659023a6b94fbbaa @falconindy committed Sep 3, 2010
Showing with 4 additions and 3 deletions.
  1. +4 −3 gobble.go
View
7 gobble.go
@@ -99,13 +99,14 @@ func copyFile(src io.Reader, dst *bufio.Writer) os.Error {
func movePkg(pkg *archpkg) os.Error {
filename := fmt.Sprintf("%s-%s-%s.%s", pkg.Name, pkg.Version, pkg.Arch, pkg.Ext)
+ srcPath := fmt.Sprintf("%s/%s", *cachePath, filename)
/* try to rename, first */
- errno := syscall.Rename(fmt.Sprintf("%s/%s", *cachePath, filename), fmt.Sprintf("%s/%s", *destPath, filename))
+ errno := syscall.Rename(srcPath, fmt.Sprintf("%s/%s", *destPath, filename))
switch errno {
case syscall.EXDEV:
- src, err := os.Open(fmt.Sprintf("%s/%s", *cachePath, filename), os.O_RDONLY, 0666)
+ src, err := os.Open(srcPath, os.O_RDONLY, 0666)
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %s\n", os.Args[0], err.String())
os.Exit(1)
@@ -123,7 +124,7 @@ func movePkg(pkg *archpkg) os.Error {
err = copyFile(src, bufio.NewWriter(dst))
if err == nil {
- return os.Remove(fmt.Sprintf("%s/%s", *cachePath, filename))
+ return os.Remove(srcPath)
}
return err /* different from err outside if */
}

0 comments on commit 7de6299

Please sign in to comment.