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
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
go-version: '1.27'

- name: Build
run: ./tools/build.sh
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
go-version: '1.27'

- name: Test
run: go test -race ./...
Expand All @@ -44,11 +44,11 @@ jobs:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: '1.26'
go-version: '1.27'
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.11.4
version: v2.13.1
verify: false
# This linter works based on the file modification when running under github actions because it's
# not given full access to the git history and therefore gets the wrong date for all files.
Expand All @@ -63,7 +63,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
go-version: '1.27'

- name: install fieldalignment
run: go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
Expand Down
2 changes: 2 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ linters:
- embeddedstructfieldcheck # we use [fieldalignment] instead
- errname
- exhaustruct
- exhaustruct_v5 # To be re-enabled once fixed https://github.com/GaijinEntertainment/go-exhaustruct/issues/168
- forbidigo
- funlen
- gochecknoglobals
- gochecknoinits
- gocritic
- godot
- godox
- gomodguard # 'gomodguard' is deprecated
- ireturn
- mnd
- nlreturn
Expand Down
6 changes: 2 additions & 4 deletions cmd/subcommands/acci-ping/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,8 @@ func (app *Application) addListener(r rune, Action func(rune) error) {
panic(fmt.Sprintf("Adding more than one listener for '%v'", r))
}
app.listeningChars[r] = terminal.ConditionalListener{
Listener: terminal.Listener{
Action: Action,
Name: "GUI Listener " + strconv.QuoteRune(r),
},
Action: Action,
Name: "GUI Listener " + strconv.QuoteRune(r),
Applicable: func(in rune) bool {
return in == r
},
Expand Down
5 changes: 3 additions & 2 deletions cmd/tab_completion/tab_completion_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Use of this source code is governed by a GPL-2 license that can be found in the LICENSE file.
//
// Copyright 2025 Lexer747
// Copyright 2025-2026 Lexer747
//
// SPDX-License-Identifier: GPL-2.0-only

Expand Down Expand Up @@ -32,6 +32,7 @@ var subCommands = []Command{
make_version_Flags(),
}

//nolint:goconst // constants are not desirable here
func TestGetChoices(t *testing.T) {
t.Parallel()
t.Run("tab", func(t *testing.T) {
Expand Down Expand Up @@ -179,7 +180,7 @@ type boolFlag interface {
IsBoolFlag() bool
}

//nolint:staticcheck
//nolint:staticcheck // ST1003 underscores are fine here we want casing to be correct for the command
func make_acciping_Flags() Command {
f := flag.NewFlagSet("", flag.ContinueOnError)
tf := tabflags.NewAutoCompleteFlagSet(f, false, "")
Expand Down
10 changes: 4 additions & 6 deletions cmd/terminal/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Use of this source code is governed by a GPL-2 license that can be found in the LICENSE file.
//
// Copyright 2024-2025 Lexer747
// Copyright 2024-2026 Lexer747
//
// SPDX-License-Identifier: GPL-2.0-only

Expand Down Expand Up @@ -48,11 +48,9 @@ func main() {
Applicable: func(r rune) bool {
return r == 'l'
},
Listener: terminal.Listener{
Name: "clear",
Action: func(rune) error {
return t.ClearScreen(terminal.UpdateSize)
},
Name: "clear",
Action: func(rune) error {
return t.ClearScreen(terminal.UpdateSize)
},
}
// Actually start the terminal program. Note that the listeners are applied in order, so if more than one
Expand Down
17 changes: 7 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
module github.com/Lexer747/acci-ping

go 1.26.0

require (
golang.org/x/exp v0.0.0-20260718201538-764159d718ef
golang.org/x/net v0.57.0
golang.org/x/term v0.45.0
)
go 1.27

// Test dependencies
require (
github.com/google/go-cmp v0.7.0
golang.org/x/exp v0.0.0-20260820142414-ca536658362e
golang.org/x/net v0.58.0
golang.org/x/term v0.45.0
gotest.tools/v3 v3.5.2
pgregory.net/rapid v1.2.0
pgregory.net/rapid v1.3.0
)

require (
golang.org/x/mod v0.38.0 // indirect
golang.org/x/mod v0.40.0 // indirect
golang.org/x/sync v0.22.0 // indirect
golang.org/x/sys v0.47.0 // indirect
golang.org/x/tools v0.48.0 // indirect
golang.org/x/tools v0.49.0 // indirect
)

tool golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
golang.org/x/exp v0.0.0-20260718201538-764159d718ef h1:LkZ48HFgy/TvhTI0bcWkjgFkgLyKUwcTbDjS0DUjw+A=
golang.org/x/exp v0.0.0-20260718201538-764159d718ef/go.mod h1:EdfpwwqSu+0Li0mzskwHU6FWDV3t9Q+RZDo3QMUtL3Q=
golang.org/x/mod v0.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk=
golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40=
golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE=
golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU=
golang.org/x/exp v0.0.0-20260820142414-ca536658362e h1:01Ju2A/fZKkci4zqx0eZxw//DnRYOnBiGJG14hFBhO8=
golang.org/x/exp v0.0.0-20260820142414-ca536658362e/go.mod h1:zeBbvyFKDaLwa7CH/zI8KXt7gTl14SF7sO08Pl5jBCM=
golang.org/x/mod v0.40.0 h1:hUv+3cXcdRHz08UmSiOob7sadHig73uo5bkXxQ/tvUs=
golang.org/x/mod v0.40.0/go.mod h1:0/weTWkPWGBikyTWAX3dkjVztMmBA5hM0DH6BElSupE=
golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To=
golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU=
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0=
golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w=
golang.org/x/tools v0.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE=
golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk=
golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI=
golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo=
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
pgregory.net/rapid v1.2.0 h1:keKAYRcjm+e1F0oAuU5F5+YPAWcyxNNRK2wud503Gnk=
pgregory.net/rapid v1.2.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
pgregory.net/rapid v1.3.0 h1:vBvO0VSqti75J1jjYqpgPNBLKMd1+gxa9fYo7vk/Exc=
pgregory.net/rapid v1.3.0/go.mod h1:dPlE4OBBxgXPqkP79flB6sJL1dx5azpI7HQ9MY9Z7uk=
6 changes: 2 additions & 4 deletions terminal/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,8 @@ func (t *Terminal) StartRaw(

controlCListener := ConditionalListener{
Applicable: func(r rune) bool { return r == '\x03' },
Listener: Listener{
Name: "ctrl+c",
Action: ctrlCAction,
},
Name: "ctrl+c",
Action: ctrlCAction,
}
t.listeners = slices.Concat(t.listeners, []ConditionalListener{controlCListener}, listeners)
if fallbacks != nil {
Expand Down
24 changes: 10 additions & 14 deletions terminal/terminal_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Use of this source code is governed by a GPL-2 license that can be found in the LICENSE file.
//
// Copyright 2024-2025 Lexer747
// Copyright 2024-2026 Lexer747
//
// SPDX-License-Identifier: GPL-2.0-only

Expand Down Expand Up @@ -61,13 +61,11 @@ func TestTerminalListener(t *testing.T) {
lastRune = r
return true
},
Listener: terminal.Listener{
Action: func(r rune) error {
assert.Equal(t, lastRune, r)
err := term.Print(string(r))
assert.NilError(t, err)
return nil
},
Action: func(r rune) error {
assert.Equal(t, lastRune, r)
err := term.Print(string(r))
assert.NilError(t, err)
return nil
},
}
_, err = term.StartRaw(ctx, cancelFunc, []terminal.ConditionalListener{testListener}, nil)
Expand Down Expand Up @@ -105,12 +103,10 @@ func TestTerminalFallbackListener(t *testing.T) {
Applicable: func(r rune) bool {
return r == 'a'
},
Listener: terminal.Listener{
Action: func(r rune) error {
<-m1
m2 <- struct{}{}
return nil
},
Action: func(r rune) error {
<-m1
m2 <- struct{}{}
return nil
},
}
fallback := terminal.Listener{
Expand Down
6 changes: 4 additions & 2 deletions utils/sliceutils/sliceutils.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Use of this source code is governed by a GPL-2 license that can be found in the LICENSE file.
//
// Copyright 2024-2025 Lexer747
// Copyright 2024-2026 Lexer747
//
// SPDX-License-Identifier: GPL-2.0-only

Expand Down Expand Up @@ -50,14 +50,16 @@ func Fold[IN, OUT any, S ~[]IN](slice S, base OUT, f func(IN, OUT) OUT) OUT {
}

// Shuffle uses [rand.Shuffle] to shuffle all the elements of the [slice] and return a shuffled [clone] of the
// input.
// input. This is not a secure shuffle as it uses a weak number generator do not call for security sensitive
// code.
func Shuffle[S ~[]T, T any](slice S) S {
ret := slices.Clone(slice)
shuf := func(i, j int) {
t := ret[i]
ret[i] = ret[j]
ret[j] = t
}
//nolint:gosec // G404 this is not a security safe function and is declared as such above
rand.Shuffle(len(ret), shuf)
return ret
}
Expand Down