Skip to content

Commit

Permalink
doc and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mh-cbon committed Jan 8, 2017
1 parent ba30202 commit 46b1b3f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions util/index.go
Expand Up @@ -9,22 +9,22 @@ import (
"path/filepath"
)

// Find path of the current binary file on the file system
// GetBinPath Find path of the current binary file on the file system
func GetBinPath() (string, error) {
var err error
wd := ""
if filepath.Base(os.Args[0]) == "main" { // go run ...
wd, err = os.Getwd()
} else {
bin := ""
bin, err = exec.LookPath(os.Args[0])
if err == nil {
bin, err2 := exec.LookPath(os.Args[0])
if err2 == nil {
wd = filepath.Dir(bin)
}
}
return wd, err
}

//CopyFile copy file src to dst.
func CopyFile(dst, src string) error {
s, err := os.Open(src)
if err != nil {
Expand All @@ -42,6 +42,7 @@ func CopyFile(dst, src string) error {
return d.Close()
}

//ComputeSha256 computes the sha256 value of a file content.
func ComputeSha256(filepath string) (string, error) {
hasher := sha256.New()
f, err := os.Open(filepath)
Expand Down

0 comments on commit 46b1b3f

Please sign in to comment.