mirror of
https://github.com/minio/mc.git
synced 2025-11-12 01:02:26 +03:00
Version is now based on MD5SUM of its binary
This commit is contained in:
28
hash-binary.go
Normal file
28
hash-binary.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"crypto/md5"
|
||||
)
|
||||
|
||||
// mustHashBinarySelf computes MD5SUM of a binary file on disk
|
||||
func hashBinary(progName string) (string, error) {
|
||||
h := md5.New()
|
||||
|
||||
file, err := os.Open(progName) // For read access.
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
io.Copy(h, file)
|
||||
return fmt.Sprintf("%x", h.Sum(nil)), nil
|
||||
}
|
||||
|
||||
// mustHashBinarySelf computes MD5SUM of its binary file on disk
|
||||
func mustHashBinarySelf() string {
|
||||
hash, _ := hashBinary(os.Args[0])
|
||||
return hash
|
||||
}
|
||||
Reference in New Issue
Block a user