Skip to content

Commit

Permalink
mod: update for go1.24
Browse files Browse the repository at this point in the history
This fixes vet complaint about the use of non-constant format string in
types.NewErr calls, and go-cmp changes due to the movement of the internal
state of sync.Mutex into an internal package.

Script tests are updated to reflect the change in build info version
printing.

The watcher tester is moved into its own module to allow gioui.org to be
updated to handle go1.24 Cgo type method constraints. This also has the
advantage that gioui.org is now no longer a dependency of dex itself.
  • Loading branch information
kortschak committed Dec 14, 2024
1 parent 7b48451 commit 776b471
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 30 deletions.
2 changes: 1 addition & 1 deletion cmd/rest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ func (extLib) decode(arg ref.Val) ref.Val {
var val any
err := json.Unmarshal(msg, &val)
if err != nil {
return types.NewErr(err.Error())
return types.NewErr("%s", err.Error())
}
return types.DefaultTypeAdapter.NativeToValue(val)
}
Expand Down
4 changes: 3 additions & 1 deletion cmd/watcher/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ func TestDaemon(t *testing.T) {
t.Fatalf("failed to build daemon: %v\n%s", err, out)
}
testerPath := filepath.Join(tmp, "tester")
out, err = execabs.Command("go", "build", "-o", testerPath, "./tester").CombinedOutput()
build := execabs.Command("go", "build", "-o", testerPath)
build.Dir = "./tester"
out, err = build.CombinedOutput()
if err != nil {
t.Fatalf("failed to build tester: %v\n%s", err, out)
}
Expand Down
16 changes: 16 additions & 0 deletions cmd/watcher/tester/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module github.com/kortschak/dex-public/cmd/watcher/tester

go 1.22.7

require gioui.org v0.7.1-0.20241206092302-1d95c7c6b336

require (
gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7 // indirect
gioui.org/shader v1.0.8 // indirect
github.com/go-text/typesetting v0.1.2 // indirect
golang.org/x/exp v0.0.0-20240707233637-46b078467d37 // indirect
golang.org/x/exp/shiny v0.0.0-20240707233637-46b078467d37 // indirect
golang.org/x/image v0.18.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
)
29 changes: 29 additions & 0 deletions cmd/watcher/tester/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d h1:ARo7NCVvN2NdhLlJE9xAbKweuI9L6UgfTbYb0YwPacY=
eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d/go.mod h1:OYVuxibdk9OSLX8vAqydtRPP87PyTFcT9uH3MlEGBQA=
gioui.org v0.7.1-0.20241206092302-1d95c7c6b336 h1:TuqAKWCZcgo7UmvegCRISO+0XHpX93p4SB/9xAsn36o=
gioui.org v0.7.1-0.20241206092302-1d95c7c6b336/go.mod h1:TpKlqfsfrWCIUN3jRZWWCzEF7LGHdXHfCvsDJ5jx9fk=
gioui.org v0.7.1 h1:l7OVj47n1z8acaszQ6Wlu+Rxme+HqF3q8b+Fs68+x3w=
gioui.org v0.7.1/go.mod h1:5Kw/q7R1BWc5MKStuTNvhCgSrRqbfHc9Dzfjs4IGgZo=
gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2 h1:AGDDxsJE1RpcXTAxPG2B4jrwVUJGFDjINIPi1jtO6pc=
gioui.org/cpu v0.0.0-20210817075930-8d6a761490d2/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7 h1:tNJdnP5CgM39PRc+KWmBRRYX/zJ+rd5XaYxY5d5veqA=
gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/shader v1.0.8 h1:6ks0o/A+b0ne7RzEqRZK5f4Gboz2CfG+mVliciy6+qA=
gioui.org/shader v1.0.8/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
github.com/go-text/typesetting v0.1.1 h1:bGAesCuo85nXnEN5LmFMVGAGpGkCPtHrZLi//qD7EJo=
github.com/go-text/typesetting v0.1.1/go.mod h1:d22AnmeKq/on0HNv73UFriMKc4Ez6EqZAofLhAzpSzI=
github.com/go-text/typesetting v0.1.2 h1:KmZOfoxrrYgghohzXgNY7aQPgQ4W+QeKPeRI8yqpDDE=
github.com/go-text/typesetting v0.1.2/go.mod h1:2+owI/sxa73XA581LAzVuEBZ3WEEV2pXeDswCH/3i1I=
github.com/go-text/typesetting-utils v0.0.0-20231211103740-d9332ae51f04 h1:zBx+p/W2aQYtNuyZNcTfinWvXBQwYtDfme051PR/lAY=
github.com/go-text/typesetting-utils v0.0.0-20231211103740-d9332ae51f04/go.mod h1:DDxDdQEnB70R8owOx3LVpEFvpMK9eeH1o2r0yZhFI9o=
golang.org/x/exp v0.0.0-20240707233637-46b078467d37 h1:uLDX+AfeFCct3a2C7uIWBKMJIR3CJMhcgfrUAqjRK6w=
golang.org/x/exp v0.0.0-20240707233637-46b078467d37/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
golang.org/x/exp/shiny v0.0.0-20240707233637-46b078467d37 h1:SOSg7+sueresE4IbmmGM60GmlIys+zNX63d6/J4CMtU=
golang.org/x/exp/shiny v0.0.0-20240707233637-46b078467d37/go.mod h1:3F+MieQB7dRYLTmnncoFbb1crS5lfQoTfDgQy6K4N0o=
golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ=
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
9 changes: 4 additions & 5 deletions cmd/watcher/tester/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@ import (
"os"

"gioui.org/app"
"gioui.org/io/system"
)

func main() {
title := flag.String("title", "", "set window title")
flag.Parse()

go func() {
w := app.NewWindow(app.Title(*title), app.Size(200, 100))
w := new(app.Window)
w.Option(app.Title(*title), app.Size(200, 100))
for {
e := <-w.Events()
switch e := e.(type) {
case system.DestroyEvent:
switch e := w.Event().(type) {
case app.DestroyEvent:
if e.Err != nil {
log.Fatal(e.Err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/worklog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1397,15 +1397,15 @@ func (l dbLib) query(arg ref.Val) ref.Val {
}
resp, err := l.db.Select(l.ctx, string(sql))
if err != nil {
return types.NewErr(err.Error())
return types.NewErr("%s", err.Error())
}
for _, row := range resp {
b, ok := row["datastr"].([]byte)
if ok && len(b) != 0 {
var d any
err := json.Unmarshal(b, &d)
if err != nil {
return types.NewErr(err.Error())
return types.NewErr("%s", err.Error())
}
row["datastr"] = d
}
Expand Down
4 changes: 0 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.22.7

require (
cuelang.org/go v0.10.0
gioui.org v0.3.1
github.com/BurntSushi/toml v1.3.2
github.com/bbrks/wrap/v2 v2.5.0
github.com/fsnotify/fsnotify v1.7.0
Expand All @@ -28,8 +27,6 @@ require (
)

require (
gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7 // indirect
gioui.org/shader v1.0.8 // indirect
github.com/ByteArena/poly2tri-go v0.0.0-20170716161910-d102ad91854f // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
Expand All @@ -53,7 +50,6 @@ require (
github.com/tdewolff/minify/v2 v2.20.5 // indirect
github.com/tdewolff/parse/v2 v2.7.15 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp/shiny v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect
Expand Down
11 changes: 0 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ cuelabs.dev/go/oci/ociregistry v0.0.0-20240807094312-a32ad29eed79 h1:EceZITBGET3
cuelabs.dev/go/oci/ociregistry v0.0.0-20240807094312-a32ad29eed79/go.mod h1:5A4xfTzHTXfeVJBU6RAUf+QrlfTCW+017q/QiW+sMLg=
cuelang.org/go v0.10.0 h1:Y1Pu4wwga5HkXfLFK1sWAYaSWIBdcsr5Cb5AWj2pOuE=
cuelang.org/go v0.10.0/go.mod h1:HzlaqqqInHNiqE6slTP6+UtxT9hN6DAzgJgdbNxXvX8=
eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d h1:ARo7NCVvN2NdhLlJE9xAbKweuI9L6UgfTbYb0YwPacY=
eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d/go.mod h1:OYVuxibdk9OSLX8vAqydtRPP87PyTFcT9uH3MlEGBQA=
gioui.org v0.3.1 h1:hslYkrkIWvx28Mxe3A87opl+8s9mnWsnWmPDh11+zco=
gioui.org v0.3.1/go.mod h1:2atiYR4upH71/6ehnh6XsUELa7JZOrOHHNMDxGBZF0Q=
gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7 h1:tNJdnP5CgM39PRc+KWmBRRYX/zJ+rd5XaYxY5d5veqA=
gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/shader v1.0.8 h1:6ks0o/A+b0ne7RzEqRZK5f4Gboz2CfG+mVliciy6+qA=
gioui.org/shader v1.0.8/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
git.sr.ht/~sbinet/gg v0.5.0 h1:6V43j30HM623V329xA9Ntq+WJrMjDxRjuAB1LFWF5m8=
git.sr.ht/~sbinet/gg v0.5.0/go.mod h1:G2C0eRESqlKhS7ErsNey6HHrqU1PwsnCQlekFi9Q2Oo=
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
Expand Down Expand Up @@ -140,8 +131,6 @@ golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8=
golang.org/x/exp/shiny v0.0.0-20231006140011-7918f672742d h1:grE48C8cjIY0aiHVmFyYgYxxSARQWBABLXKZfQPrBhY=
golang.org/x/exp/shiny v0.0.0-20231006140011-7918f672742d/go.mod h1:UH99kUObWAZkDnWqppdQe5ZhPYESUw8I0zVV1uWBR+0=
golang.org/x/image v0.0.0-20210504121937-7319ad40d33e/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.21.0 h1:c5qV36ajHpdj4Qi0GnE0jUc/yuo33OLFaa0d+crTD5s=
golang.org/x/image v0.21.0/go.mod h1:vUbsLavqK/W303ZroQQVKQ+Af3Yl6Uz1Ppu5J/cLz78=
Expand Down
12 changes: 8 additions & 4 deletions internal/device/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"time"

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
)

var (
Expand All @@ -28,6 +29,9 @@ func TestPauser(t *testing.T) {
atomic.Bool{},
sync.Mutex{},
)
comparable := cmpopts.EquateComparable(
sync.Mutex{},
)
ignore := cmp.FilterValues(
func(_, _ chan struct{}) bool { return true },
cmp.Ignore(),
Expand All @@ -39,8 +43,8 @@ func TestPauser(t *testing.T) {
p2.pause()
p2.pause()

if !cmp.Equal(&p1, &p2, allow, ignore) {
t.Errorf("pause is not idempotent:\n--- p1:\n+++ p2:\n%s", cmp.Diff(&p1, &p2, allow, ignore))
if !cmp.Equal(&p1, &p2, allow, ignore, comparable) {
t.Errorf("pause is not idempotent:\n--- p1:\n+++ p2:\n%s", cmp.Diff(&p1, &p2, allow, ignore, comparable))
}
})
t.Run("unpause_no_panic", func(t *testing.T) {
Expand All @@ -63,8 +67,8 @@ func TestPauser(t *testing.T) {
p2.unpause()
p2.unpause()

if !cmp.Equal(&p1, &p2, allow, ignore) {
t.Errorf("unpause is not idempotent:\n--- p1:\n+++ p2:\n%s", cmp.Diff(&p1, &p2, allow, ignore))
if !cmp.Equal(&p1, &p2, allow, ignore, comparable) {
t.Errorf("unpause is not idempotent:\n--- p1:\n+++ p2:\n%s", cmp.Diff(&p1, &p2, allow, ignore, comparable))
}
})
t.Run("pause_pauses", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion testdata/debug.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ network = "tcp"
"command": ".*/bin/rest -log_stdout -uid debug -network tcp -addr 127\.0\.0\.1:.*",
"has_drop": false,
"uid": "debug",
"version": "(?:\(devel\) )?[^ ]+(?: \(modified\))?"
"version": "(?:(?:\(devel\)|v[0-9]\.[0-9]\.[0-9]-[0-9]{14}-[0-9a-f]{12}(?:\+dirty))? )?[0-9a-f]+(?: \(modified\))?"
}
},
"funcs": \[
Expand Down
2 changes: 1 addition & 1 deletion testdata/rest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ response.body
"command": ".*/bin/rest -log_stdout -uid rest -network tcp -addr 127\.0\.0\.1:.*",
"has_drop": false,
"uid": "rest",
"version": "(?:\(devel\) )?[^ ]+(?: \(modified\))?"
"version": "(?:(?:\(devel\)|v[0-9]\.[0-9]\.[0-9]-[0-9]{14}-[0-9a-f]{12}(?:\+dirty))? )?[0-9a-f]+(?: \(modified\))?"
}
},
"funcs": \[
Expand Down

0 comments on commit 776b471

Please sign in to comment.