Browse Source

fix bug for stdin checksumming

recursive
Stephen McQuay 4 years ago
parent
commit
19870e8911
No known key found for this signature in database GPG Key ID: 1ABF428F71BAFC3D
1 changed files with 12 additions and 8 deletions
  1. +12
    -8
      hash.go

+ 12
- 8
hash.go View File

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

Loading…
Cancel
Save