Update golangci-lint to v2.12.2 with canonical config (closes #60)
check / check (push) Has been cancelled
check / check (push) Has been cancelled
Adopts golangci-lint v2.12.2 and the canonical .golangci.yml (default: all), and fixes all resulting findings across the tree. Two intended behavior changes: absent MFFilePath.Mtime is handled explicitly in freshen, list and export rather than dereferenced (main panicked); gpg positional key IDs now follow an explicit -- end-of-options marker. All twelve reworded user-visible error messages restored to byte-identical parity with main and pinned by tests.
This commit was merged in pull request #59.
This commit is contained in:
1 parent
6d19de74e7
commit
de476708e9
40 files changed
+4012
-1798
No files matched your search
+28
-13
@@ -9,9 +9,18 @@ import (
|
||||
"github.com/multiformats/go-multihash"
|
||||
)
|
||||
|
||||
var (
|
||||
errOuterNotSet = errors.New("pbOuter not set")
|
||||
errUUIDNotSet = errors.New("UUID not set")
|
||||
errSHA256NotSet = errors.New("SHA256 hash not set")
|
||||
)
|
||||
|
||||
// manifest holds the internal representation of a manifest file.
|
||||
// Use NewManifestFromFile or NewManifestFromReader to load an existing manifest,
|
||||
// or use Builder to create a new one.
|
||||
// Use NewManifestFromFile or NewManifestFromReader to load an existing
|
||||
// manifest, or use Builder to create a new one.
|
||||
//
|
||||
// Whether this type should be exported is an open design question owned by
|
||||
// the repository owner; see README design question 13.
|
||||
type manifest struct {
|
||||
pbInner *MFFile
|
||||
pbOuter *MFFileOuter
|
||||
@@ -23,8 +32,9 @@ type manifest struct {
|
||||
func (m *manifest) String() string {
|
||||
count := 0
|
||||
if m.pbInner != nil {
|
||||
count = len(m.pbInner.Files)
|
||||
count = len(m.pbInner.GetFiles())
|
||||
}
|
||||
|
||||
return fmt.Sprintf("<Manifest count=%d>", count)
|
||||
}
|
||||
|
||||
@@ -33,7 +43,8 @@ func (m *manifest) Files() []*MFFilePath {
|
||||
if m.pbInner == nil {
|
||||
return nil
|
||||
}
|
||||
return m.pbInner.Files
|
||||
|
||||
return m.pbInner.GetFiles()
|
||||
}
|
||||
|
||||
// signatureString generates the canonical string used for signing/verification.
|
||||
@@ -41,20 +52,24 @@ func (m *manifest) Files() []*MFFilePath {
|
||||
// Requires pbOuter to be set with Uuid and Sha256 fields.
|
||||
func (m *manifest) signatureString() (string, error) {
|
||||
if m.pbOuter == nil {
|
||||
return "", errors.New("pbOuter not set")
|
||||
}
|
||||
if len(m.pbOuter.Uuid) == 0 {
|
||||
return "", errors.New("UUID not set")
|
||||
}
|
||||
if len(m.pbOuter.Sha256) == 0 {
|
||||
return "", errors.New("SHA256 hash not set")
|
||||
return "", errOuterNotSet
|
||||
}
|
||||
|
||||
mh, err := multihash.Encode(m.pbOuter.Sha256, multihash.SHA2_256)
|
||||
if len(m.pbOuter.GetUuid()) == 0 {
|
||||
return "", errUUIDNotSet
|
||||
}
|
||||
|
||||
if len(m.pbOuter.GetSha256()) == 0 {
|
||||
return "", errSHA256NotSet
|
||||
}
|
||||
|
||||
mh, err := multihash.Encode(m.pbOuter.GetSha256(), multihash.SHA2_256)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to encode multihash: %w", err)
|
||||
}
|
||||
uuidStr := hex.EncodeToString(m.pbOuter.Uuid)
|
||||
|
||||
uuidStr := hex.EncodeToString(m.pbOuter.GetUuid())
|
||||
mhStr := hex.EncodeToString(mh)
|
||||
|
||||
return fmt.Sprintf("%s-%s-%s", MAGIC, uuidStr, mhStr), nil
|
||||
}
|
||||
Reference in new issue
Block a user