Update dependencies

This commit is contained in:
9seconds
2022-08-08 16:51:47 +03:00
parent 36dad5a2f6
commit 53dde2aafa
3 changed files with 82 additions and 80 deletions
+17 -26
View File
@@ -45,20 +45,33 @@ func getVersion() string {
}
hasher := sha256.New()
if _, err := io.WriteString(hasher, buildInfo.Path); err != nil {
panic(err)
checksumModule := func(mod *debug.Module) {
hasher.Write([]byte{buildInfoModuleStart})
io.WriteString(hasher, mod.Path) //nolint: errcheck
hasher.Write([]byte{buildInfoModuleDelimeter})
io.WriteString(hasher, mod.Version) //nolint: errcheck
hasher.Write([]byte{buildInfoModuleDelimeter})
io.WriteString(hasher, mod.Sum) //nolint: errcheck
hasher.Write([]byte{buildInfoModuleFinish})
}
io.WriteString(hasher, buildInfo.Path) //nolint: errcheck
binary.Write(hasher, binary.LittleEndian, uint64(1+len(buildInfo.Deps))) //nolint: errcheck
sort.Slice(buildInfo.Deps, func(i, j int) bool {
return buildInfo.Deps[i].Path > buildInfo.Deps[j].Path
})
buildInfoCheckSumModule(hasher, &buildInfo.Main)
checksumModule(&buildInfo.Main)
for _, module := range buildInfo.Deps {
buildInfoCheckSumModule(hasher, module)
checksumModule(module)
}
return fmt.Sprintf("%s (%s: %s on %s%s, modules checksum %s)",
@@ -69,25 +82,3 @@ func getVersion() string {
dirtySuffix,
base64.StdEncoding.EncodeToString(hasher.Sum(nil)))
}
func buildInfoCheckSumModule(w io.Writer, module *debug.Module) {
w.Write([]byte{buildInfoModuleStart}) //nolint: errcheck
if _, err := io.WriteString(w, module.Path); err != nil {
panic(err)
}
w.Write([]byte{buildInfoModuleDelimeter}) //nolint: errcheck
if _, err := io.WriteString(w, module.Version); err != nil {
panic(err)
}
w.Write([]byte{buildInfoModuleDelimeter}) //nolint: errcheck
if _, err := io.WriteString(w, module.Sum); err != nil {
panic(err)
}
w.Write([]byte{buildInfoModuleFinish}) //nolint: errcheck
}