fix: satisfy stricter Go 1.26.1 linter checks

Go 1.26.1 tightens a few toolchain checks that older builds tolerated.\n\nCast aliased replication status values back to their defining type before calling the generated msgp helpers, and replace Sprintf+WriteString pairs with direct Fprintf calls where needed.\n\nThese are compatibility-only source changes to keep the cmd package building cleanly under the newer linker/toolchain.
This commit is contained in:
Feng Ruohang
2026-03-21 13:43:15 +08:00
parent 5abd9a80f6
commit 377fc616d9
3 changed files with 10 additions and 10 deletions
+5 -5
View File
@@ -903,7 +903,7 @@ func (z *ReplicationState) DecodeMsg(dc *msgp.Reader) (err error) {
return return
} }
var za0004 VersionPurgeStatusType var za0004 VersionPurgeStatusType
err = za0004.DecodeMsg(dc) err = (*replication.VersionPurgeStatusType)(&za0004).DecodeMsg(dc)
if err != nil { if err != nil {
err = msgp.WrapError(err, "PurgeTargets", za0003) err = msgp.WrapError(err, "PurgeTargets", za0003)
return return
@@ -1060,7 +1060,7 @@ func (z *ReplicationState) EncodeMsg(en *msgp.Writer) (err error) {
err = msgp.WrapError(err, "PurgeTargets") err = msgp.WrapError(err, "PurgeTargets")
return return
} }
err = za0004.EncodeMsg(en) err = (*replication.VersionPurgeStatusType)(&za0004).EncodeMsg(en)
if err != nil { if err != nil {
err = msgp.WrapError(err, "PurgeTargets", za0003) err = msgp.WrapError(err, "PurgeTargets", za0003)
return return
@@ -1136,7 +1136,7 @@ func (z *ReplicationState) MarshalMsg(b []byte) (o []byte, err error) {
o = msgp.AppendMapHeader(o, uint32(len(z.PurgeTargets))) o = msgp.AppendMapHeader(o, uint32(len(z.PurgeTargets)))
for za0003, za0004 := range z.PurgeTargets { for za0003, za0004 := range z.PurgeTargets {
o = msgp.AppendString(o, za0003) o = msgp.AppendString(o, za0003)
o, err = za0004.MarshalMsg(o) o, err = (*replication.VersionPurgeStatusType)(&za0004).MarshalMsg(o)
if err != nil { if err != nil {
err = msgp.WrapError(err, "PurgeTargets", za0003) err = msgp.WrapError(err, "PurgeTargets", za0003)
return return
@@ -1261,7 +1261,7 @@ func (z *ReplicationState) UnmarshalMsg(bts []byte) (o []byte, err error) {
err = msgp.WrapError(err, "PurgeTargets") err = msgp.WrapError(err, "PurgeTargets")
return return
} }
bts, err = za0004.UnmarshalMsg(bts) bts, err = (*replication.VersionPurgeStatusType)(&za0004).UnmarshalMsg(bts)
if err != nil { if err != nil {
err = msgp.WrapError(err, "PurgeTargets", za0003) err = msgp.WrapError(err, "PurgeTargets", za0003)
return return
@@ -1321,7 +1321,7 @@ func (z *ReplicationState) Msgsize() (s int) {
if z.PurgeTargets != nil { if z.PurgeTargets != nil {
for za0003, za0004 := range z.PurgeTargets { for za0003, za0004 := range z.PurgeTargets {
_ = za0004 _ = za0004
s += msgp.StringPrefixSize + len(za0003) + za0004.Msgsize() s += msgp.StringPrefixSize + len(za0003) + (*replication.VersionPurgeStatusType)(&za0004).Msgsize()
} }
} }
s += 17 + msgp.MapHeaderSize s += 17 + msgp.MapHeaderSize
+1 -1
View File
@@ -576,7 +576,7 @@ func (iamOS *IAMObjectStore) loadAllFromObjStore(ctx context.Context, cache *iam
if took := time.Since(listStartTime); took > maxIAMLoadOpTime { if took := time.Since(listStartTime); took > maxIAMLoadOpTime {
var s strings.Builder var s strings.Builder
for k, v := range listedConfigItems { for k, v := range listedConfigItems {
s.WriteString(fmt.Sprintf(" %s: %d items\n", k, len(v))) fmt.Fprintf(&s, " %s: %d items\n", k, len(v))
} }
logger.Info("listAllIAMConfigItems took %.2fs with contents:\n%s", took.Seconds(), s.String()) logger.Info("listAllIAMConfigItems took %.2fs with contents:\n%s", took.Seconds(), s.String())
} }
+4 -4
View File
@@ -2128,7 +2128,7 @@ func (s *TestSuiteCommon) TestGetObjectLarge10MiB(c *check) {
1234567890,1234567890,1234567890,1234567890,1234567890,123"` 1234567890,1234567890,1234567890,1234567890,1234567890,123"`
// Create 10MiB content where each line contains 1024 characters. // Create 10MiB content where each line contains 1024 characters.
for i := range 10 * 1024 { for i := range 10 * 1024 {
buffer.WriteString(fmt.Sprintf("[%05d] %s\n", i, line)) fmt.Fprintf(&buffer, "[%05d] %s\n", i, line)
} }
putContent := buffer.String() putContent := buffer.String()
@@ -2190,7 +2190,7 @@ func (s *TestSuiteCommon) TestGetObjectLarge11MiB(c *check) {
1234567890,1234567890,1234567890,123` 1234567890,1234567890,1234567890,123`
// Create 11MiB content where each line contains 1024 characters. // Create 11MiB content where each line contains 1024 characters.
for i := range 11 * 1024 { for i := range 11 * 1024 {
buffer.WriteString(fmt.Sprintf("[%05d] %s\n", i, line)) fmt.Fprintf(&buffer, "[%05d] %s\n", i, line)
} }
putMD5 := getMD5Hash(buffer.Bytes()) putMD5 := getMD5Hash(buffer.Bytes())
@@ -2341,7 +2341,7 @@ func (s *TestSuiteCommon) TestGetPartialObjectLarge11MiB(c *check) {
// Create 11MiB content where each line contains 1024 // Create 11MiB content where each line contains 1024
// characters. // characters.
for i := range 11 * 1024 { for i := range 11 * 1024 {
buffer.WriteString(fmt.Sprintf("[%05d] %s\n", i, line)) fmt.Fprintf(&buffer, "[%05d] %s\n", i, line)
} }
putContent := buffer.String() putContent := buffer.String()
@@ -2407,7 +2407,7 @@ func (s *TestSuiteCommon) TestGetPartialObjectLarge10MiB(c *check) {
1234567890,1234567890,1234567890,123` 1234567890,1234567890,1234567890,123`
// Create 10MiB content where each line contains 1024 characters. // Create 10MiB content where each line contains 1024 characters.
for i := range 10 * 1024 { for i := range 10 * 1024 {
buffer.WriteString(fmt.Sprintf("[%05d] %s\n", i, line)) fmt.Fprintf(&buffer, "[%05d] %s\n", i, line)
} }
putContent := buffer.String() putContent := buffer.String()