this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

all: various very small cleanups from gopls and staticcheck

I had been accumulating tiny tweaks and cleanups that were too small
to require a commit or review of their own.

* doTasks has had an unused parameter for a long time.
* publishRegistryResolverShim has an unused field.
* writeIndex did not actually check an error from os.WriteFile.
* extractFeatures can prepare the right slice capacities ahead of time.
* A few places can avoid the type parameter in generic func calls;
note that type inference got much better with Go 1.21.
* zeroReader.Read can make use of the new clear builtin in Go 1.21

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I4206073007191c28782acebe926c00ce3c3498db
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1194842
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Noam Dolovich <noam.tzvi.dolovich@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>

+10 -12
+2 -2
cmd/cue/cmd/custom.go
··· 141 141 // - parse flags and env vars 142 142 // - constrain current config with config section 143 143 144 - return doTasks(cmd, typ, name, tools) 144 + return doTasks(cmd, name, tools) 145 145 }), 146 146 } 147 147 ··· 149 149 return sub, nil 150 150 } 151 151 152 - func doTasks(cmd *Command, typ, command string, root *cue.Instance) error { 152 + func doTasks(cmd *Command, command string, root *cue.Instance) error { 153 153 cfg := &flow.Config{ 154 154 Root: cue.MakePath(cue.Str(commandSection), cue.Str(command)), 155 155 InferTasks: true,
+2 -3
cmd/cue/cmd/modpublish.go
··· 162 162 if err != nil { 163 163 return err 164 164 } 165 - if err := modzip.Create[string](zf, mv, files, osFileIO{ 165 + if err := modzip.Create(zf, mv, files, osFileIO{ 166 166 modRoot: modRoot, 167 167 }); err != nil { 168 168 return err ··· 253 253 // module's zip file. 254 254 type publishRegistryResolverShim struct { 255 255 resolver *modconfig.Resolver 256 - registry ociregistry.Interface 257 256 dryRun bool 258 257 recordFiles bool 259 258 outDir string ··· 320 319 return err 321 320 } 322 321 data = append(data, '\n') 323 - if os.WriteFile(filepath.Join(r.outDir, "index.json"), data, 0o666); err != nil { 322 + if err := os.WriteFile(filepath.Join(r.outDir, "index.json"), data, 0o666); err != nil { 324 323 return err 325 324 } 326 325 return nil
+3 -2
internal/core/export/toposort.go
··· 52 52 } 53 53 54 54 func extractFeatures(in []*adt.StructInfo) (a [][]adt.Feature) { 55 + a = make([][]adt.Feature, 0, len(in)) 55 56 for _, s := range in { 56 - sorted := []adt.Feature{} 57 - for _, e := range s.StructLit.Decls { 57 + sorted := make([]adt.Feature, 0, len(s.Decls)) 58 + for _, e := range s.Decls { 58 59 switch x := e.(type) { 59 60 case *adt.Field: 60 61 sorted = append(sorted, x.Label)
+2 -2
mod/modzip/zip.go
··· 374 374 if err != nil { 375 375 return CheckedFiles{}, err 376 376 } 377 - cf, cfErr := CheckFiles[dirFile](files, dirFileIO{}) 377 + cf, cfErr := CheckFiles(files, dirFileIO{}) 378 378 _ = cfErr // ignore this error; we'll generate our own after rewriting paths. 379 379 380 380 // Replace all paths with file system paths. ··· 595 595 return err 596 596 } 597 597 598 - return Create[dirFile](w, m, files, dirFileIO{}) 598 + return Create(w, m, files, dirFileIO{}) 599 599 } 600 600 601 601 type dirFile struct {
+1 -3
mod/modzip/zip_test.go
··· 179 179 type zeroReader struct{} 180 180 181 181 func (r zeroReader) Read(b []byte) (int, error) { 182 - for i := range b { 183 - b[i] = 0 184 - } 182 + clear(b) 185 183 return len(b), nil 186 184 } 187 185