MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / ExecutableChecksum

Function ExecutableChecksum

x/init.go:95–116  ·  view source on GitHub ↗

ExecutableChecksum returns a byte slice containing the SHA256 checksum of the executable. It returns a nil slice if there's an error trying to calculate the checksum.

()

Source from the content-addressed store, hash-verified

93// ExecutableChecksum returns a byte slice containing the SHA256 checksum of the executable.
94// It returns a nil slice if there's an error trying to calculate the checksum.
95func ExecutableChecksum() []byte {
96 execPath, err := os.Executable()
97 if err != nil {
98 return nil
99 }
100 execFile, err := os.Open(execPath)
101 if err != nil {
102 return nil
103 }
104 defer func() {
105 if err := execFile.Close(); err != nil {
106 glog.Warningf("error closing file: %v", err)
107 }
108 }()
109
110 h := sha256.New()
111 if _, err := io.Copy(h, execFile); err != nil {
112 return nil
113 }
114
115 return h.Sum(nil)
116}

Callers 1

BuildDetailsFunction · 0.85

Calls 3

WarningfMethod · 0.80
OpenMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected