fix bug for stdin checksumming

This commit is contained in:
Stephen McQuay 2016-11-16 01:27:11 -08:00
parent 9e4d6b8f9e
commit 19870e8911
No known key found for this signature in database
GPG Key ID: 1ABF428F71BAFC3D
1 changed files with 12 additions and 8 deletions

View File

@ -43,14 +43,18 @@ func hsh(files []string) chan result {
} }
if len(files) == 0 { if len(files) == 0 {
r := make(chan result)
go func() {
hsh := h() hsh := h()
_, err := io.Copy(hsh, os.Stdin) _, err := io.Copy(hsh, os.Stdin)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err) fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1) os.Exit(1)
} }
fmt.Printf("%x -\n", hsh.Sum(nil)) r <- result{msg: fmt.Sprintf("%x -", hsh.Sum(nil))}
return nil close(r)
}()
return r
} }
jobs := make(chan checksum) jobs := make(chan checksum)