loader logic revised
This commit is contained in:
+21
-1
@@ -1,6 +1,7 @@
|
||||
package loader
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"galaxy/connector"
|
||||
"galaxy/util"
|
||||
@@ -12,7 +13,7 @@ func resolvePluginFile(version string) string {
|
||||
return libUIPluginFile + "-" + version
|
||||
}
|
||||
|
||||
// latestVersion should return VersionInfo with the latest Version for the current OD
|
||||
// latestVersion should return VersionInfo with the latest Version for the current OS
|
||||
func latestVersion(versions []connector.VersionInfo) (connector.VersionInfo, bool, error) {
|
||||
os := runtime.GOOS
|
||||
versions = slices.DeleteFunc(versions, func(v connector.VersionInfo) bool { return v.OS != os })
|
||||
@@ -37,3 +38,22 @@ func latestVersion(versions []connector.VersionInfo) (connector.VersionInfo, boo
|
||||
slices.SortFunc(semvers, func(a, b *v) int { return util.CompareSemver(*b.sv, *a.sv) })
|
||||
return *semvers[0].vi, true, nil
|
||||
}
|
||||
|
||||
// SumSHA256 calculates SHA-256 for the provided byte slice and returns
|
||||
// the raw 32-byte digest as a fixed-size array.
|
||||
//
|
||||
// The function does not modify the input data.
|
||||
// The returned value is the binary digest, not a hex string.
|
||||
// Use digest[:] if a []byte is needed.
|
||||
func SumSHA256(data []byte) [32]byte {
|
||||
return sha256.Sum256(data)
|
||||
}
|
||||
|
||||
// EqualSHA256 returns true when both SHA-256 digests are identical.
|
||||
//
|
||||
// Since SHA-256 digest is represented as a fixed-size array [32]byte,
|
||||
// Go allows direct value comparison with ==.
|
||||
// This is the simplest and fastest approach for ordinary equality checks.
|
||||
func EqualSHA256(a, b [32]byte) bool {
|
||||
return a == b
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user