Skip to content
This repository has been archived by the owner on Oct 10, 2020. It is now read-only.

Dockertar sha256 helper enhancements #1117

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions dockertar-sha256-helper.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package main

import (
"fmt"
"compress/gzip"
"os"
"io"
"crypto/sha256"
"fmt"
"io"
"os"
)

func main() {
// Require one positional argument
if len(os.Args) != 2 {
panic("One positional argument is required")
}
reader, err := os.Open(os.Args[1])
// Close the input file at the end of the function
defer reader.Close()
if err != nil {
os.Exit(1)
}
Expand All @@ -29,7 +35,8 @@ func main() {
panic(err)
}
}
// We must explicitly close before executing the sum
// as defer will cause an incorrect result
w.Close()

fmt.Printf("%x\n", sha_256.Sum(nil))
}