lint: gopls fixes

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2025-09-09 14:00:36 +02:00
parent 060be8484d
commit d31230ea96
22 changed files with 50 additions and 50 deletions

View File

@@ -15,7 +15,7 @@ var Buf []byte
func BenchmarkMarshalVertex(b *testing.B) {
v := sampleVertex()
for i := 0; i < b.N; i++ {
for b.Loop() {
var err error
Buf, err = v.MarshalVT()
require.NoError(b, err)
@@ -24,7 +24,7 @@ func BenchmarkMarshalVertex(b *testing.B) {
func BenchmarkMarshalVertexStatus(b *testing.B) {
v := sampleVertexStatus()
for i := 0; i < b.N; i++ {
for b.Loop() {
var err error
Buf, err = v.MarshalVT()
require.NoError(b, err)
@@ -33,7 +33,7 @@ func BenchmarkMarshalVertexStatus(b *testing.B) {
func BenchmarkMarshalVertexLog(b *testing.B) {
v := sampleVertexLog()
for i := 0; i < b.N; i++ {
for b.Loop() {
var err error
Buf, err = v.MarshalVT()
require.NoError(b, err)
@@ -47,7 +47,7 @@ func BenchmarkUnmarshalVertex(b *testing.B) {
buf, err := proto.Marshal(v)
require.NoError(b, err)
for i := 0; i < b.N; i++ {
for b.Loop() {
err := VertexOutput.UnmarshalVT(buf)
require.NoError(b, err)
}
@@ -60,7 +60,7 @@ func BenchmarkUnmarshalVertexStatus(b *testing.B) {
buf, err := proto.Marshal(v)
require.NoError(b, err)
for i := 0; i < b.N; i++ {
for b.Loop() {
err := VertexStatusOutput.UnmarshalVT(buf)
require.NoError(b, err)
}
@@ -73,7 +73,7 @@ func BenchmarkUnmarshalVertexLog(b *testing.B) {
buf, err := proto.Marshal(v)
require.NoError(b, err)
for i := 0; i < b.N; i++ {
for b.Loop() {
err := VertexLogOutput.UnmarshalVT(buf)
require.NoError(b, err)
}

View File

@@ -13,7 +13,7 @@ var Buf []byte
func BenchmarkMarshalCacheRecords(b *testing.B) {
v := sampleCacheRecords()
for i := 0; i < b.N; i++ {
for b.Loop() {
var err error
Buf, err = v.MarshalVT()
require.NoError(b, err)
@@ -27,7 +27,7 @@ func BenchmarkUnmarshalCacheRecords(b *testing.B) {
buf, err := proto.Marshal(v)
require.NoError(b, err)
for i := 0; i < b.N; i++ {
for b.Loop() {
err := CacheRecordsOutput.UnmarshalVT(buf)
require.NoError(b, err)
}

View File

@@ -23,7 +23,7 @@ type LayerAnnotations struct {
MediaType string `json:"mediaType,omitempty"`
DiffID digest.Digest `json:"diffID,omitempty"`
Size int64 `json:"size,omitempty"`
CreatedAt time.Time `json:"createdAt,omitempty"`
CreatedAt time.Time `json:"createdAt"`
}
type CacheRecord struct {
@@ -35,12 +35,12 @@ type CacheRecord struct {
type CacheResult struct {
LayerIndex int `json:"layer"`
CreatedAt time.Time `json:"createdAt,omitempty"`
CreatedAt time.Time `json:"createdAt"`
}
type ChainedResult struct {
LayerIndexes []int `json:"layers"`
CreatedAt time.Time `json:"createdAt,omitempty"`
CreatedAt time.Time `json:"createdAt"`
}
type CacheInput struct {

View File

@@ -24,7 +24,7 @@ type VertexStatus struct {
Name string `json:"name,omitempty"`
Total int64 `json:"total,omitempty"`
Current int64 `json:"current"`
Timestamp time.Time `json:"timestamp,omitempty"`
Timestamp time.Time `json:"timestamp"`
Started *time.Time `json:"started,omitempty"`
Completed *time.Time `json:"completed,omitempty"`
}

View File

@@ -81,7 +81,7 @@ func (r *testResolver) ResolveImageConfig(ctx context.Context, ref string, opt s
Env []string `json:"Env,omitempty"`
WorkingDir string `json:"WorkingDir,omitempty"`
User string `json:"User,omitempty"`
} `json:"config,omitempty"`
} `json:"config"`
}
r.called = true

View File

@@ -44,7 +44,7 @@ func getLocalListener(listenerPath, secDescriptor string) (net.Listener, error)
func groupToSecurityDescriptor(group string) (string, error) {
sddl := "D:P(A;;GA;;;BA)(A;;GA;;;SY)"
if group != "" {
for _, g := range strings.Split(group, ",") {
for g := range strings.SplitSeq(group, ",") {
sid, err := winio.LookupSidByName(g)
if err != nil {
return "", errors.Wrapf(err, "failed to lookup sid for group %s", g)

View File

@@ -43,7 +43,7 @@ func xmain() error {
return err
}
var nodes []string
for _, s := range strings.Split(string(stdin), "\n") {
for s := range strings.SplitSeq(string(stdin), "\n") {
s = strings.TrimSpace(s)
if s != "" {
nodes = append(nodes, s)

View File

@@ -35,8 +35,8 @@ func getCgroupIOStat(cgroupPath string) (*resourcestypes.IOStat, error) {
}
ioStat := &resourcestypes.IOStat{}
lines := strings.Split(string(data), "\n")
for _, line := range lines {
lines := strings.SplitSeq(string(data), "\n")
for line := range lines {
parts := strings.Fields(line)
if len(parts) < 2 {
continue

View File

@@ -138,8 +138,8 @@ func parseKeyValueFile(filePath string, callback func(key string, value uint64))
return errors.Wrapf(err, "failed to read %s", filePath)
}
lines := strings.Split(string(content), "\n")
for _, line := range lines {
lines := strings.SplitSeq(string(content), "\n")
for line := range lines {
if len(strings.TrimSpace(line)) == 0 {
continue
}

View File

@@ -273,7 +273,7 @@ func prepareCgroupControllers() error {
if err != nil {
return err
}
for _, c := range strings.Split(string(dt), " ") {
for c := range strings.SplitSeq(string(dt), " ") {
if c == "" {
continue
}

View File

@@ -271,8 +271,8 @@ func (e *imageExporterInstance) Export(ctx context.Context, src *exporter.Source
}
if e.opts.ImageName != "" {
targetNames := strings.Split(e.opts.ImageName, ",")
for _, targetName := range targetNames {
targetNames := strings.SplitSeq(e.opts.ImageName, ",")
for targetName := range targetNames {
if e.opt.Images != nil && e.store {
tagDone := progress.OneOff(ctx, "naming to "+targetName)

View File

@@ -296,7 +296,7 @@ func (ic *ImageWriter) Commit(ctx context.Context, inp *exporter.Source, session
}
var defaultSubjects []intoto.Subject
for _, name := range strings.Split(opts.ImageName, ",") {
for name := range strings.SplitSeq(opts.ImageName, ",") {
if name == "" {
continue
}

View File

@@ -20,8 +20,8 @@ func validateCaps(req string) (forward bool, err error) {
if req == "" {
return
}
caps := strings.Split(req, ",")
for _, c := range caps {
caps := strings.SplitSeq(req, ",")
for c := range caps {
parts := strings.SplitN(c, "+", 2)
if _, ok := enabledCaps[parts[0]]; !ok {
err = stack.Enable(grpcerrors.WrapCode(errdefs.NewUnsupportedFrontendCapError(parts[0]), codes.Unimplemented))

View File

@@ -275,7 +275,7 @@ func TestRunCmdFlagsUsed(t *testing.T) {
func BenchmarkParseBuildStageName(b *testing.B) {
b.ReportAllocs()
stageNames := []string{"STAGE_NAME", "StageName", "St4g3N4m3"}
for i := 0; i < b.N; i++ {
for b.Loop() {
for _, s := range stageNames {
_, _ = parseBuildStageName([]string{"foo", "as", s})
}

View File

@@ -17,7 +17,7 @@ import (
func parsePlatforms(v string) ([]ocispecs.Platform, error) {
var pp []ocispecs.Platform
for _, v := range strings.Split(v, ",") {
for v := range strings.SplitSeq(v, ",") {
p, err := platforms.Parse(v)
if err != nil {
return nil, errors.Wrapf(err, "failed to parse target platform %s", v)

View File

@@ -237,8 +237,8 @@ func (bc *Client) init() error {
}
// old API
if cacheFromStr := opts[keyCacheFrom]; cacheFromStr != "" {
cacheFrom := strings.Split(cacheFromStr, ",")
for _, s := range cacheFrom {
cacheFrom := strings.SplitSeq(cacheFromStr, ",")
for s := range cacheFrom {
im := client.CacheOptionsEntry{
Type: "registry",
Attrs: map[string]string{

View File

@@ -103,33 +103,33 @@ func (ps *ProvenanceSLSA) Validate() error {
type ProvenancePredicateSLSA02 struct {
slsa02.ProvenancePredicate
Invocation ProvenanceInvocationSLSA02 `json:"invocation,omitempty"`
Invocation ProvenanceInvocationSLSA02 `json:"invocation"`
BuildConfig *BuildConfig `json:"buildConfig,omitempty"`
Metadata *ProvenanceMetadataSLSA02 `json:"metadata,omitempty"`
}
type ProvenanceInvocationSLSA02 struct {
ConfigSource slsa02.ConfigSource `json:"configSource,omitempty"`
Parameters Parameters `json:"parameters,omitempty"`
Environment Environment `json:"environment,omitempty"`
ConfigSource slsa02.ConfigSource `json:"configSource"`
Parameters Parameters `json:"parameters"`
Environment Environment `json:"environment"`
}
type ProvenanceMetadataSLSA02 struct {
slsa02.ProvenanceMetadata
BuildKitMetadata BuildKitMetadata `json:"https://mobyproject.org/buildkit@v1#metadata,omitempty"`
BuildKitMetadata BuildKitMetadata `json:"https://mobyproject.org/buildkit@v1#metadata"`
Hermetic bool `json:"https://mobyproject.org/buildkit@v1#hermetic,omitempty"`
}
type ProvenancePredicateSLSA1 struct {
slsa1.ProvenancePredicate
BuildDefinition ProvenanceBuildDefinitionSLSA1 `json:"buildDefinition,omitempty"`
RunDetails ProvenanceRunDetailsSLSA1 `json:"runDetails,omitempty"`
BuildDefinition ProvenanceBuildDefinitionSLSA1 `json:"buildDefinition"`
RunDetails ProvenanceRunDetailsSLSA1 `json:"runDetails"`
}
type ProvenanceBuildDefinitionSLSA1 struct {
slsa1.ProvenanceBuildDefinition
ExternalParameters ProvenanceExternalParametersSLSA1 `json:"externalParameters,omitempty"`
InternalParameters ProvenanceInternalParametersSLSA1 `json:"internalParameters,omitempty"`
ExternalParameters ProvenanceExternalParametersSLSA1 `json:"externalParameters"`
InternalParameters ProvenanceInternalParametersSLSA1 `json:"internalParameters"`
}
type ProvenanceRunDetailsSLSA1 struct {
@@ -138,8 +138,8 @@ type ProvenanceRunDetailsSLSA1 struct {
}
type ProvenanceExternalParametersSLSA1 struct {
ConfigSource ProvenanceConfigSourceSLSA1 `json:"configSource,omitempty"`
Request Parameters `json:"request,omitempty"`
ConfigSource ProvenanceConfigSourceSLSA1 `json:"configSource"`
Request Parameters `json:"request"`
}
type ProvenanceConfigSourceSLSA1 struct {
@@ -155,9 +155,9 @@ type ProvenanceInternalParametersSLSA1 struct {
type ProvenanceMetadataSLSA1 struct {
slsa1.BuildMetadata
BuildKitMetadata BuildKitMetadata `json:"buildkit_metadata,omitempty"`
BuildKitMetadata BuildKitMetadata `json:"buildkit_metadata"`
Hermetic bool `json:"buildkit_hermetic,omitempty"`
Completeness BuildKitComplete `json:"buildkit_completeness,omitempty"`
Completeness BuildKitComplete `json:"buildkit_completeness"`
Reproducible bool `json:"buildkit_reproducible,omitempty"`
}

View File

@@ -121,11 +121,11 @@ func (r *Record) LoadSubRecords(loader func(d digest.Digest) (Type, []Frame, err
}
}
case TypeDigestList:
for _, dgst := range bytes.Split(dt, []byte{0}) {
for dgst := range bytes.SplitSeq(dt, []byte{0}) {
checksums = append(checksums, string(dgst))
}
case TypeFileList:
for _, nameChecksumPair := range bytes.Split(dt, []byte{0}) {
for nameChecksumPair := range bytes.SplitSeq(dt, []byte{0}) {
idx := bytes.LastIndex(nameChecksumPair, []byte("sha256:"))
if idx < 0 {
bklog.L.Warnf("invalid file list entry %q, missing sha256 prefix", nameChecksumPair)

View File

@@ -697,7 +697,7 @@ func BenchmarkGenerate(b *testing.B) {
}
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for b.Loop() {
_, err := rc.Generate(true)
if err != nil {
b.Fatal(err)

View File

@@ -453,7 +453,7 @@ func parseScopes(s []string) scopes {
return nil
}
// The scopeStr may have strings that contain multiple scopes separated by a space.
for _, scope := range strings.Split(scopeStr, " ") {
for scope := range strings.SplitSeq(scopeStr, " ") {
parts := strings.SplitN(scope, ":", 3)
names := []string{parts[0]}
if len(parts) > 1 {

View File

@@ -3,7 +3,7 @@ package dockerd
type Config struct {
Features map[string]bool `json:"features,omitempty"`
Mirrors []string `json:"registry-mirrors,omitempty"`
Builder BuilderConfig `json:"builder,omitempty"`
Builder BuilderConfig `json:"builder"`
}
type BuilderEntitlements struct {
@@ -13,5 +13,5 @@ type BuilderEntitlements struct {
}
type BuilderConfig struct {
Entitlements BuilderEntitlements `json:",omitempty"`
Entitlements BuilderEntitlements
}

View File

@@ -25,8 +25,8 @@ func InitContainerdWorker() {
// defined in Dockerfile
// e.g. `containerd-1.1=/opt/containerd-1.1/bin,containerd-42.0=/opt/containerd-42.0/bin`
if s := os.Getenv("BUILDKIT_INTEGRATION_CONTAINERD_EXTRA"); s != "" {
entries := strings.Split(s, ",")
for _, entry := range entries {
entries := strings.SplitSeq(s, ",")
for entry := range entries {
pair := strings.Split(strings.TrimSpace(entry), "=")
if len(pair) != 2 {
panic(errors.Errorf("unexpected BUILDKIT_INTEGRATION_CONTAINERD_EXTRA: %q", s))