Skip to content

Commit daa31f1

Browse files
authored
Merge branch 'main' into 2025-08-21-14-48-18
2 parents 6705296 + 066809b commit daa31f1

17 files changed

Lines changed: 1022 additions & 906 deletions

.github/workflows/deadcode.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Dead Code (manual)
2+
3+
# Manually-triggered, report-only scan for dead code that the standard `unused`
4+
# linter cannot catch: unexported symbols referenced only from test files.
5+
# staticcheck (like golangci-lint's `unused`) counts test references as usage,
6+
# so this job strips *_test.go and re-runs staticcheck, surfacing test-only
7+
# symbols as unused (U1000). It never modifies the repo and never posts; the
8+
# findings are written to the run summary. It does not fail the run, because
9+
# some flagged symbols may be intentionally test-only (review each by hand).
10+
11+
on:
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
deadcode:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
23+
24+
- name: Set up Go
25+
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
26+
with:
27+
go-version: stable
28+
29+
- name: Install staticcheck
30+
run: go install honnef.co/go/tools/cmd/staticcheck@latest
31+
32+
- name: Detect test-only dead code (report only)
33+
run: |
34+
work="$(mktemp -d)"
35+
rsync -a --exclude='.git' ./ "$work/"
36+
find "$work" -name '*_test.go' -delete
37+
cd "$work"
38+
{
39+
echo "## Dead code report (test-only / unused)"
40+
echo
41+
echo "Unexported symbols unused once test files are removed."
42+
echo "Some may be intentional test-only helpers; review each by hand."
43+
echo
44+
echo '```'
45+
} >> "$GITHUB_STEP_SUMMARY"
46+
staticcheck -checks=U1000 ./... 2>&1 | tee -a "$GITHUB_STEP_SUMMARY" || true
47+
echo '```' >> "$GITHUB_STEP_SUMMARY"

.github/workflows/release-drafter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jobs:
2121
runs-on: ubuntu-latest
2222
timeout-minutes: 10
2323
steps:
24-
- uses: release-drafter/release-drafter@ed4bc48ec97379be2258e7b7ac2624a3e26ab809 # v7
24+
- uses: release-drafter/release-drafter@73b95fa1c286dfd6802a4f949b07dad6149f2b0f # v7

client/core.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ import (
77
"context"
88
"errors"
99
"fmt"
10-
"net"
1110
"slices"
12-
"strconv"
13-
"strings"
1411
"sync"
1512

1613
"github.com/valyala/fasthttp"
@@ -33,19 +30,6 @@ type ResponseHook func(*Client, *Response, *Request) error
3330
// RetryConfig is an alias for the `retry.Config` type from the `addon/retry` package.
3431
type RetryConfig = retry.Config
3532

36-
// addMissingPort appends the appropriate port number to the given address if it doesn't have one.
37-
// If isTLS is true, it uses port 443; otherwise, it uses port 80.
38-
func addMissingPort(addr string, isTLS bool) string { //revive:disable-line:flag-parameter
39-
if strings.IndexByte(addr, ':') != -1 {
40-
return addr
41-
}
42-
port := 80
43-
if isTLS {
44-
port = 443
45-
}
46-
return net.JoinHostPort(addr, strconv.Itoa(port))
47-
}
48-
4933
// core stores middleware and plugin definitions and defines the request execution process.
5034
type core struct {
5135
client *Client

client/core_test.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -18,49 +18,6 @@ import (
1818
"github.com/gofiber/fiber/v3"
1919
)
2020

21-
func Test_AddMissing_Port(t *testing.T) {
22-
t.Parallel()
23-
24-
type args struct {
25-
addr string
26-
isTLS bool
27-
}
28-
tests := []struct {
29-
name string
30-
want string
31-
args args
32-
}{
33-
{
34-
name: "do anything",
35-
args: args{
36-
addr: "example.com:1234",
37-
},
38-
want: "example.com:1234",
39-
},
40-
{
41-
name: "add 80 port",
42-
args: args{
43-
addr: "example.com",
44-
},
45-
want: "example.com:80",
46-
},
47-
{
48-
name: "add 443 port",
49-
args: args{
50-
addr: "example.com",
51-
isTLS: true,
52-
},
53-
want: "example.com:443",
54-
},
55-
}
56-
for _, tt := range tests {
57-
t.Run(tt.name, func(t *testing.T) {
58-
t.Parallel()
59-
require.Equal(t, tt.want, addMissingPort(tt.args.addr, tt.args.isTLS))
60-
})
61-
}
62-
}
63-
6421
func Test_Exec_Func(t *testing.T) {
6522
t.Parallel()
6623
ln := fasthttputil.NewInmemoryListener()

helpers.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -219,20 +219,6 @@ func (*App) isASCII(s string) bool {
219219
return true
220220
}
221221

222-
// uniqueRouteStack drop all not unique routes from the slice
223-
func uniqueRouteStack(stack []*Route) []*Route {
224-
m := make(map[*Route]struct{}, len(stack))
225-
unique := make([]*Route, 0, len(stack))
226-
for _, v := range stack {
227-
if _, ok := m[v]; !ok {
228-
m[v] = struct{}{}
229-
unique = append(unique, v)
230-
}
231-
}
232-
233-
return unique
234-
}
235-
236222
// defaultString returns the value or a default value if it is set
237223
func defaultString(value string, defaultValue []string) string {
238224
if value == "" && len(defaultValue) > 0 {

helpers_test.go

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -630,35 +630,6 @@ func Benchmark_Utils_SortAcceptedTypes_Unsorted(b *testing.B) {
630630
}, acceptedTypes)
631631
}
632632

633-
func Test_Utils_UniqueRouteStack(t *testing.T) {
634-
t.Parallel()
635-
route1 := &Route{}
636-
route2 := &Route{}
637-
route3 := &Route{}
638-
require.Equal(
639-
t,
640-
[]*Route{
641-
route1,
642-
route2,
643-
route3,
644-
},
645-
uniqueRouteStack([]*Route{
646-
route1,
647-
route1,
648-
route1,
649-
route2,
650-
route2,
651-
route2,
652-
route3,
653-
route3,
654-
route3,
655-
route1,
656-
route2,
657-
route3,
658-
}),
659-
)
660-
}
661-
662633
func Test_Utils_getGroupPath(t *testing.T) {
663634
t.Parallel()
664635
res := getGroupPath("/v1", "/")

0 commit comments

Comments
 (0)