aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2018-05-24 22:23:56 +0700
committerShulhan <ms@kilabit.info>2018-05-24 22:23:56 +0700
commitbb551cb628cc3a7fd7fb34000c64ac51b7b1d153 (patch)
tree081d550f0e09ddd8a163abf08f71643d7f2c9ad5
parent4f4754c2fbd7912f20e87da9d42cc04e660aa101 (diff)
downloadbeku-bb551cb628cc3a7fd7fb34000c64ac51b7b1d153.tar.xz
Replace "log" with "fmt"
-rw-r--r--beku_test.go17
-rw-r--r--cmd/beku/command.go15
-rw-r--r--cmd/beku/main.go2
-rw-r--r--common.go3
-rw-r--r--env.go11
-rw-r--r--package.go11
-rw-r--r--package_git.go3
7 files changed, 31 insertions, 31 deletions
diff --git a/beku_test.go b/beku_test.go
index bc116a9..e41640e 100644
--- a/beku_test.go
+++ b/beku_test.go
@@ -1,10 +1,10 @@
package beku
import (
+ "fmt"
"go/build"
"io"
"io/ioutil"
- "log"
"os"
"testing"
)
@@ -79,7 +79,8 @@ func TestMain(m *testing.M) {
testGOPATH, err := os.Getwd()
if err != nil {
- log.Fatal(err)
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(1)
}
testGOPATH += "/testdata"
@@ -91,21 +92,23 @@ func TestMain(m *testing.M) {
err = testInitOutput()
if err != nil {
- log.Fatal(err)
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(1)
}
testEnv, err = NewEnvironment()
if err != nil {
- log.Fatal(err)
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(1)
}
testGitPkgCur = NewPackage(testGitRepo, testGitRepo, VCSModeGit)
testGitPkgNew = NewPackage(testGitRepo, testGitRepo, VCSModeGit)
testGitPkgShare = NewPackage(testGitRepoShare, testGitRepoShare, VCSModeGit)
- log.Printf("test env : %+v\n", *testEnv)
- log.Printf("testGitPkgCur: %+v\n", *testGitPkgCur)
- log.Printf("testGitPkgNew: %+v\n", *testGitPkgNew)
+ fmt.Printf("test env : %+v\n", *testEnv)
+ fmt.Printf("testGitPkgCur: %+v\n", *testGitPkgCur)
+ fmt.Printf("testGitPkgNew: %+v\n", *testGitPkgNew)
os.Exit(m.Run())
}
diff --git a/cmd/beku/command.go b/cmd/beku/command.go
index 208ea62..15ee035 100644
--- a/cmd/beku/command.go
+++ b/cmd/beku/command.go
@@ -3,7 +3,6 @@ package main
import (
"errors"
"fmt"
- "log"
"os"
"github.com/shuLhan/beku"
@@ -231,15 +230,17 @@ func (cmd *command) loadDatabase() (err error) {
func (cmd *command) firstTime() {
err := cmd.env.Scan()
if err != nil {
- log.Fatal("Scan:", err)
+ fmt.Fprintln(os.Stderr, ">>> Scan:", err)
+ os.Exit(1)
}
err = cmd.env.Save("")
if err != nil {
- log.Fatal("Save:", err)
+ fmt.Fprintln(os.Stderr, ">>> Save:", err)
+ os.Exit(1)
}
- log.Println("Initialization complete.")
+ fmt.Println("Initialization complete.")
}
func newCommand() (err error) {
@@ -257,13 +258,13 @@ func newCommand() (err error) {
err = cmd.loadDatabase()
if err != nil {
- log.Println("No database found.")
- log.Println("Initializing database for the first time...")
+ fmt.Println("No database found.")
+ fmt.Println("Initializing database for the first time...")
cmd.firstTime()
}
if beku.Debug >= beku.DebugL2 {
- log.Printf("Environment: %s", cmd.env)
+ fmt.Printf("Environment: %s", cmd.env)
}
return
diff --git a/cmd/beku/main.go b/cmd/beku/main.go
index d869c21..7460cb4 100644
--- a/cmd/beku/main.go
+++ b/cmd/beku/main.go
@@ -22,7 +22,7 @@
//
// ## Remove Operation
//
-// -R, --remove [pkg]
+// -R, --remove <pkg>
//
// Remove package from GOPATH, including source and installed binaries and
// archives.
diff --git a/common.go b/common.go
index 121ee31..c4015c4 100644
--- a/common.go
+++ b/common.go
@@ -9,7 +9,6 @@ import (
"bytes"
"fmt"
"io"
- "log"
"os"
"strings"
)
@@ -103,7 +102,7 @@ func confirm(in io.Reader, msg string, defIsYes bool) bool {
for {
b, err = r.ReadByte()
if err != nil {
- log.Println(err)
+ fmt.Fprintln(os.Stderr, err)
break
}
if b == ' ' || b == '\t' {
diff --git a/env.go b/env.go
index 5673314..9a6f15e 100644
--- a/env.go
+++ b/env.go
@@ -12,7 +12,6 @@ import (
"fmt"
"go/build"
"io/ioutil"
- "log"
"os"
"path/filepath"
"strconv"
@@ -157,7 +156,7 @@ func (env *Env) scanStdPackages(srcPath string) error {
//
func (env *Env) scanPackages(rootPath string) (err error) {
if Debug >= DebugL2 {
- log.Println("Scanning", rootPath)
+ fmt.Println(">>> Scanning", rootPath)
}
fis, err := ioutil.ReadDir(rootPath)
@@ -217,7 +216,7 @@ func (env *Env) newPackage(fullPath string, vcsMode VCSMode) (err error) {
pkg := NewPackage(pkgName, pkgName, vcsMode)
if Debug >= DebugL2 {
- log.Println("Scanning package:", pkg.ImportPath)
+ fmt.Println(">>> Scanning package:", pkg.ImportPath)
}
err = pkg.Scan()
@@ -267,7 +266,7 @@ func (env *Env) Load(file string) (err error) {
}
if Debug >= DebugL1 {
- log.Println("Env.Load:", env.dbFile)
+ fmt.Println(">>> Env.Load:", env.dbFile)
}
env.db, err = ini.Open(env.dbFile)
@@ -278,7 +277,7 @@ func (env *Env) Load(file string) (err error) {
sections := env.db.GetSections(sectionPackage)
for _, sec := range sections {
if len(sec.Sub) == 0 {
- log.Println(errDBPackageName, sec.LineNum, env.dbFile)
+ fmt.Fprintln(os.Stderr, errDBPackageName, sec.LineNum, env.dbFile)
continue
}
@@ -577,7 +576,7 @@ func (env *Env) update(curPkg, newPkg *Package) (ok bool, err error) {
}
if Debug >= DebugL1 {
- log.Println("Sync:\n", newPkg)
+ fmt.Println(">>> Sync:\n", newPkg)
}
if curPkg.IsEqual(newPkg) {
diff --git a/package.go b/package.go
index 0c923f2..ec847f6 100644
--- a/package.go
+++ b/package.go
@@ -8,7 +8,6 @@ import (
"bytes"
"fmt"
"go/build"
- "log"
"os"
"os/exec"
"path/filepath"
@@ -229,7 +228,7 @@ func (pkg *Package) ScanDeps(env *Env) (err error) {
}
if Debug >= DebugL2 && len(imports) > 0 {
- log.Println(" imports recursive:", imports)
+ fmt.Println(" imports recursive:", imports)
}
for x := 0; x < len(imports); x++ {
@@ -307,7 +306,7 @@ func (pkg *Package) addDep(env *Env, importPath string) bool {
// (1)
if strings.HasPrefix(importPath, pkg.ImportPath) {
if Debug >= DebugL2 {
- log.Printf("%15s >>> %s\n", dbgSkipSelf, importPath)
+ fmt.Printf("%15s >>> %s\n", dbgSkipSelf, importPath)
}
return false
}
@@ -324,7 +323,7 @@ func (pkg *Package) addDep(env *Env, importPath string) bool {
continue
}
if Debug >= DebugL2 {
- log.Printf("%15s >>> %s\n", dbgSkipStd, importPath)
+ fmt.Printf("%15s >>> %s\n", dbgSkipStd, importPath)
}
return false
}
@@ -342,7 +341,7 @@ func (pkg *Package) addDep(env *Env, importPath string) bool {
}
if Debug >= DebugL2 {
- log.Printf("%15s >>> %s\n", dbgMissDep, importPath)
+ fmt.Printf("%15s >>> %s\n", dbgMissDep, importPath)
}
pkg.pushMissing(importPath)
@@ -505,7 +504,7 @@ func (pkg *Package) pushDep(importPath string) bool {
pkg.Deps = append(pkg.Deps, importPath)
if Debug >= DebugL2 {
- log.Printf("%15s >>> %s\n", dbgLinkDep, importPath)
+ fmt.Printf("%15s >>> %s\n", dbgLinkDep, importPath)
}
return true
diff --git a/package_git.go b/package_git.go
index 8f43b47..c223960 100644
--- a/package_git.go
+++ b/package_git.go
@@ -3,7 +3,6 @@ package beku
import (
"bytes"
"fmt"
- "log"
"os"
"os/exec"
"path/filepath"
@@ -234,7 +233,7 @@ func (pkg *Package) gitRemoteChange(newPkg *Package) (err error) {
err = cmd.Run()
if err != nil {
- log.Println("gitRemoteChange:", err)
+ fmt.Fprintln(defStderr, "gitRemoteChange:", err)
}
//nolint:gas