Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/zb/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ func (f pathMapFlag) Get() any {
}

func (f pathMapFlag) Set(s string) error {
for _, word := range strings.Fields(s) {
for word := range strings.FieldsSeq(s) {
k, v, isMap := strings.Cut(word, "=")
if !isMap {
v = k
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

inherit (pkgs.lib.attrsets) optionalAttrs;

go = pkgs.go_1_25;
buildGoModule = pkgs.buildGo125Module;
go = pkgs.go_1_26;
buildGoModule = pkgs.buildGo126Module;

zbPackage = pkgs.callPackage ./package.nix {
inherit buildGoModule;
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module zb.256lights.llc/pkg

go 1.25.2
go 1.26.0

toolchain go1.26.1

require (
github.com/coreos/go-systemd/v22 v22.5.0
Expand Down
12 changes: 4 additions & 8 deletions internal/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,13 @@ func NewServer(dir zbstore.Directory, dbPath string, opts *Options) *Server {
}
var bgCtx context.Context
bgCtx, srv.cancelBackground = context.WithCancel(context.Background())
srv.background.Add(1)
go func() {
defer srv.background.Done()
srv.background.Go(func() {
srv.optimizeDatabase(bgCtx)
}()
})
if opts.BuildLogRetention > 0 {
srv.background.Add(1)
go func() {
defer srv.background.Done()
srv.background.Go(func() {
srv.gcLogs(bgCtx, opts.BuildLogRetention)
}()
})
}
return srv
}
Expand Down
2 changes: 1 addition & 1 deletion internal/backend/builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func TestExtractZip(t *testing.T) {
}
}

var mapFileType = reflect.TypeOf((*fstest.MapFile)(nil)).Elem()
var mapFileType = reflect.TypeFor[fstest.MapFile]()

func diffFS(tb testing.TB, fsys1, fsys2 fs.FS) string {
map1 := loadFS(tb, fsys1)
Expand Down
8 changes: 2 additions & 6 deletions internal/backend/realize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os"
"reflect"
"runtime"
"slices"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -1309,12 +1310,7 @@ func isFieldAnyOf[T any](p cmp.Path, names ...string) bool {
return false
}
name := p.Last().(cmp.StructField).Name()
for _, n := range names {
if name == n {
return true
}
}
return false
return slices.Contains(names, name)
}

func checkSingleFileOutput(tb testing.TB, drvPath, wantOutputPath zbstore.Path, wantOutputContent []byte, resp *zbstorerpc.Build) {
Expand Down
6 changes: 2 additions & 4 deletions internal/backendtest/backendtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,10 @@ func NewServer(ctx context.Context, tb TB, storeDir zbstore.Directory, opts *Opt
serverCodec := zbstorerpc.NewCodec(serverConn, &zbstorerpc.CodecOptions{
Importer: zbstorerpc.NewReceiverImporter(serverReceiver),
})
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
jsonrpc.Serve(backend.WithExporter(serveCtx, serverCodec), serverCodec, srv)
serverCodec.Close()
}()
})

clientCodec := zbstorerpc.NewCodec(clientConn, &opts.ClientOptions)
client := jsonrpc.NewClient(func(ctx context.Context) (jsonrpc.ClientCodec, error) {
Expand Down
1 change: 0 additions & 1 deletion internal/jsonrpc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ func TestClient(t *testing.T) {
var wg sync.WaitGroup
wg.Add(len(test.calls))
for i, call := range test.calls {
i, call := i, call
go func() {
defer wg.Done()
codec.waitUntil(call.waitUntil)
Expand Down
6 changes: 2 additions & 4 deletions internal/jsonrpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,9 @@ func Serve(ctx context.Context, codec ServerCodec, handler Handler) error {
srv.mu.Unlock()
}

wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
srv.single(requestCtx, handler, parsed, cancel)
}()
})
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/jsonrpc/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ func TestServe(t *testing.T) {
}

var (
anyType = reflect.TypeOf((*any)(nil)).Elem()
mapStringAnyType = reflect.TypeOf((*map[string]any)(nil)).Elem()
anyType = reflect.TypeFor[any]()
mapStringAnyType = reflect.TypeFor[map[string]any]()
)

type testServerCodec struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/lua/auxlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func setFuncs(l *State, nUp int, reg map[string]Function, pushFunction func(l *S
if f == nil {
l.PushBoolean(false)
} else {
for i := 0; i < nUp; i++ {
for range nUp {
l.PushValue(-nUp)
}
pushFunction(l, nUp, f)
Expand Down
1 change: 0 additions & 1 deletion internal/lua/stringlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func OpenString(ctx context.Context, l *State) (int, error) {
indexMethod := luacode.TagMethodIndex.String()
metaMethods[indexMethod] = nil
for _, op := range operators {
op := op // Capture constant instead of loop variable.
metaMethods[op.TagMethod().String()] = func(ctx context.Context, l *State) (int, error) {
return stringArithmetic(ctx, l, op)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/luacode/funcstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (fs *funcState) finish() error {
fs.Code[i] = instruction
case OpJMP:
target := i
for count := 0; count < 100; count++ {
for range 100 {
curr := fs.Code[target]
if curr.OpCode() != OpJMP {
break
Expand Down
4 changes: 2 additions & 2 deletions internal/lualex/lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ func (s *Scanner) findClosingLongBracket(w io.ByteWriter, n int) error {
if err := w.WriteByte(']'); err != nil {
return err
}
for i := 0; i < n; i++ {
for range n {
if err := w.WriteByte('='); err != nil {
return err
}
Expand All @@ -586,7 +586,7 @@ searchStart:
}

// Consume equal signs.
for i := 0; i < n; i++ {
for i := range n {
b, err := s.readByteNoEOF()
if err != nil {
writePartial(i)
Expand Down
6 changes: 3 additions & 3 deletions internal/macho/code_signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,11 @@ func (cd *CodeDirectory) UnmarshalBinary(data []byte) error {
}

func parseCString(b []byte) (string, error) {
i := bytes.IndexByte(b, 0)
if i < 0 {
before, _, ok := bytes.Cut(b, []byte{0})
if !ok {
return "", errors.New("missing nul byte")
}
return string(b[:i]), nil
return string(before), nil
}

func isZero(b []byte) bool {
Expand Down
6 changes: 3 additions & 3 deletions internal/macho/load_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,11 @@ func unmarshalLoadCommand(byteOrder binary.ByteOrder, data []byte) (LoadCmd, err
}

func nameToString(name []byte) string {
i := bytes.IndexByte(name, 0)
if i < 0 {
before, _, ok := bytes.Cut(name, []byte{0})
if !ok {
return string(name)
}
return string(name[:i])
return string(before)
}

func decreaseCounter(count uint32, n int) uint32 {
Expand Down
2 changes: 1 addition & 1 deletion sets/bit.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (s *Bit) All() iter.Seq[uint] {
curr += bitWordSize
continue
}
for j := 0; j < bitWordSize; j++ {
for j := range bitWordSize {
if s.words[i]&(1<<j) != 0 {
if !yield(curr) {
return
Expand Down
6 changes: 3 additions & 3 deletions zbstore/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ func (fsys cacheFS) Open(name string) (fs.File, error) {
}

func firstPathElement(name string) string {
i := strings.IndexByte(name, '/')
if i < 0 {
before, _, ok := strings.Cut(name, "/")
if !ok {
return name
}
return name[:i]
return before
}
Loading