Skip to content

Commit 5c1ddd0

Browse files
committed
migrate to v3
git checkout master -- . ':!.github' ':!*.md' find . -name go.mod -execdir sh -c 'echo "=== $(pwd) ==="; fiber migrate --to v3.0.0-rc.3 -f' \;
1 parent 3597308 commit 5c1ddd0

File tree

347 files changed

+3763
-1833
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

347 files changed

+3763
-1833
lines changed
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
#!/usr/bin/env bash
2+
# parallel-go-build.sh
3+
# Recursively find go.mod files and run `go build ./...` in each module directory.
4+
# - truncates build-errors.log at start
5+
# - appends failures immediately, annotated with source line + 1-line context
6+
# - runs in parallel (jobs = CPU cores)
7+
# - atomic appends (mkdir lock)
8+
# - handles Ctrl+C (SIGINT) and SIGTERM: kills children and cleans up
9+
# - colored terminal output (OK = green, FAIL = red, WARN = yellow)
10+
set -euo pipefail
11+
IFS=$'\n\t'
12+
13+
JOBS="$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 4)"
14+
LOGFILE="build-errors.log"
15+
16+
# Colors (only if stdout is a tty)
17+
if [ -t 1 ]; then
18+
GREEN=$'\e[32m'
19+
RED=$'\e[31m'
20+
YELLOW=$'\e[33m'
21+
RESET=$'\e[0m'
22+
else
23+
GREEN=""
24+
RED=""
25+
YELLOW=""
26+
RESET=""
27+
fi
28+
29+
# truncate central logfile at start
30+
: > "$LOGFILE"
31+
32+
# find all module directories (skip common vendor trees)
33+
mapfile -t MODULE_DIRS < <(
34+
find . \( -path "./.git" -o -path "./vendor" -o -path "./node_modules" \) -prune -o \
35+
-type f -name 'go.mod' -print0 |
36+
xargs -0 -n1 dirname |
37+
sort -u
38+
)
39+
40+
if [ "${#MODULE_DIRS[@]}" -eq 0 ]; then
41+
printf '%s\n' "No go.mod files found. Nothing to do."
42+
exit 0
43+
fi
44+
45+
# create absolute temp dir
46+
TMPDIR="$(mktemp -d 2>/dev/null || mktemp -d /tmp/build-logs.XXXXXX)"
47+
if [ -z "$TMPDIR" ] || [ ! -d "$TMPDIR" ]; then
48+
printf '%s\n' "Failed to create temporary directory" >&2
49+
exit 2
50+
fi
51+
52+
# ensure cleanup on exit (will try multiple times)
53+
cleanup_tmpdir() {
54+
local attempts=0
55+
while [ "$attempts" -lt 5 ]; do
56+
if rm -rf "$TMPDIR" 2>/dev/null; then
57+
break
58+
fi
59+
attempts=$((attempts+1))
60+
sleep 0.1
61+
done
62+
if [ -d "$TMPDIR" ]; then
63+
printf '%s\n' "WARNING: could not fully remove temporary dir: $TMPDIR"
64+
fi
65+
}
66+
67+
# signal handling: kill children, wait, cleanup, exit
68+
pids=()
69+
on_interrupt() {
70+
printf '%b\n' "${YELLOW}Received interrupt. Killing background jobs...${RESET}"
71+
# kill all tracked background pids
72+
for pid in "${pids[@]:-}"; do
73+
if kill -0 "$pid" 2>/dev/null; then
74+
kill "$pid" 2>/dev/null || true
75+
fi
76+
done
77+
# give them a moment, then force
78+
sleep 0.1
79+
for pid in "${pids[@]:-}"; do
80+
if kill -0 "$pid" 2>/dev/null; then
81+
kill -9 "$pid" 2>/dev/null || true
82+
fi
83+
done
84+
cleanup_tmpdir
85+
printf '%b\n' "${YELLOW}Aborted by user.${RESET}"
86+
exit 130
87+
}
88+
trap on_interrupt INT TERM
89+
90+
# helper: sanitize a dir to a filename-safe token
91+
sanitize_name() {
92+
local d="$1"
93+
d="${d#./}"
94+
d="${d//\//__}"
95+
d="${d// /_}"
96+
printf '%s' "${d//[^A-Za-z0-9._-]/_}"
97+
}
98+
99+
# annotate a module's temp log and append to central logfile atomically
100+
annotate_and_append() {
101+
local src_log="$1" # absolute path to per-module temp log
102+
local module_dir="$2"
103+
local lockdir="$TMPDIR/.lock"
104+
105+
# create annotated temp file
106+
local annotated
107+
annotated="$(mktemp "$TMPDIR/annotated.XXXXXX")" || {
108+
# fallback: append raw log
109+
until mkdir "$lockdir" 2>/dev/null; do sleep 0.01; done
110+
printf '==== %s ====\n' "$module_dir" >> "$LOGFILE"
111+
cat "$src_log" >> "$LOGFILE"
112+
rm -f "$src_log" || true
113+
rmdir "$lockdir" 2>/dev/null || true
114+
return
115+
}
116+
117+
# process lines: if matches file.go:LINE[:COL] annotate with source snippet
118+
while IFS= read -r line || [ -n "$line" ]; do
119+
# regex: capture path ending with .go, line number, optional column, rest
120+
if [[ $line =~ ^([^:]+\.go):([0-9]+):?([0-9]*)[:[:space:]]*(.*)$ ]]; then
121+
local fp="${BASH_REMATCH[1]}"
122+
local ln="${BASH_REMATCH[2]}"
123+
local col="${BASH_REMATCH[3]}"
124+
local rest="${BASH_REMATCH[4]}"
125+
local candidate=""
126+
127+
# try to resolve file path: as-is, relative to module_dir, or relative to repo root
128+
if [ -f "$fp" ]; then
129+
candidate="$fp"
130+
elif [ -f "$module_dir/$fp" ]; then
131+
candidate="$module_dir/$fp"
132+
elif [ -f "./$fp" ]; then
133+
candidate="./$fp"
134+
fi
135+
136+
if [ -n "$candidate" ]; then
137+
# pick context: line-1 .. line+1
138+
local start=$(( ln > 1 ? ln - 1 : 1 ))
139+
local end=$(( ln + 1 ))
140+
printf '%s\n' "---- source: $candidate:$ln ----" >> "$annotated"
141+
# print numbered context lines
142+
awk -v s="$start" -v e="$end" 'NR>=s && NR<=e { printf("%6d %s\n", NR, $0) }' "$candidate" >> "$annotated"
143+
printf '%s\n\n' "Error: $line" >> "$annotated"
144+
else
145+
printf '%s\n' "---- (source not found) $line ----" >> "$annotated"
146+
fi
147+
else
148+
# plain copy line
149+
printf '%s\n' "$line" >> "$annotated"
150+
fi
151+
done < "$src_log"
152+
153+
# append annotated file to central logfile under lock
154+
until mkdir "$lockdir" 2>/dev/null; do
155+
sleep 0.01
156+
done
157+
{
158+
printf '==== %s ====\n' "$module_dir"
159+
cat "$annotated"
160+
printf '\n\n'
161+
} >> "$LOGFILE"
162+
rm -f "$annotated" "$src_log" || true
163+
rmdir "$lockdir" 2>/dev/null || true
164+
}
165+
166+
# run build for one module
167+
run_build() {
168+
local module_dir="$1"
169+
local safe
170+
safe="$(sanitize_name "$module_dir")"
171+
local mod_log="$TMPDIR/$safe.log"
172+
mkdir -p "$(dirname "$mod_log")"
173+
174+
# run inside subshell to avoid changing caller's cwd
175+
if ( cd "$module_dir" 2>/dev/null && go build ./... >/dev/null 2>"$mod_log" ); then
176+
printf '%b\n' "${GREEN}OK: ${RESET}$module_dir"
177+
rm -f "$mod_log" >/dev/null 2>&1 || true
178+
return 0
179+
else
180+
# ensure we captured something
181+
if [ ! -s "$mod_log" ]; then
182+
( cd "$module_dir" 2>/dev/null && go build ./... >"$mod_log" 2>&1 ) || true
183+
fi
184+
printf '%b\n' "${RED}FAIL: ${RESET}$module_dir (appending to $LOGFILE)"
185+
annotate_and_append "$mod_log" "$module_dir"
186+
return 1
187+
fi
188+
}
189+
190+
# main launcher: spawn jobs, throttle to JOBS, wait properly
191+
fail_count=0
192+
193+
for md in "${MODULE_DIRS[@]}"; do
194+
run_build "$md" &
195+
pids+=( "$!" )
196+
197+
# if we reached jobs, wait for the oldest launched
198+
if [ "${#pids[@]}" -ge "$JOBS" ]; then
199+
if wait "${pids[0]}"; then
200+
: # success
201+
else
202+
fail_count=$((fail_count+1))
203+
fi
204+
# drop first pid
205+
pids=( "${pids[@]:1}" )
206+
fi
207+
done
208+
209+
# wait remaining background jobs
210+
for pid in "${pids[@]:-}"; do
211+
if wait "$pid"; then :; else fail_count=$((fail_count+1)); fi
212+
done
213+
214+
# final cleanup and status
215+
cleanup_tmpdir
216+
217+
if [ "$fail_count" -gt 0 ]; then
218+
printf '\n%b\n' "${RED}Done. $fail_count module(s) failed. See $LOGFILE for details (annotated snippets included).${RESET}"
219+
exit 1
220+
else
221+
printf '\n%b\n' "${GREEN}Done. All modules built successfully.${RESET}"
222+
# remove logfile if empty
223+
if [ -f "$LOGFILE" ] && [ ! -s "$LOGFILE" ]; then
224+
rm -f "$LOGFILE"
225+
fi
226+
exit 0
227+
fi

404-handler/go.mod

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@ module main
22

33
go 1.25.0
44

5-
require github.com/gofiber/fiber/v2 v2.52.10
5+
require github.com/gofiber/fiber/v3 v3.0.0-rc.3
66

77
require (
88
github.com/andybalholm/brotli v1.2.0 // indirect
9-
github.com/clipperhouse/stringish v0.1.1 // indirect
10-
github.com/clipperhouse/uax29/v2 v2.3.0 // indirect
9+
github.com/gofiber/schema v1.6.0 // indirect
10+
github.com/gofiber/utils/v2 v2.0.0-rc.2 // indirect
1111
github.com/google/uuid v1.6.0 // indirect
1212
github.com/klauspost/compress v1.18.1 // indirect
1313
github.com/mattn/go-colorable v0.1.14 // indirect
1414
github.com/mattn/go-isatty v0.0.20 // indirect
15-
github.com/mattn/go-runewidth v0.0.19 // indirect
15+
github.com/philhofer/fwd v1.2.0 // indirect
16+
github.com/tinylib/msgp v1.5.0 // indirect
1617
github.com/valyala/bytebufferpool v1.0.0 // indirect
1718
github.com/valyala/fasthttp v1.68.0 // indirect
19+
golang.org/x/crypto v0.44.0 // indirect
20+
golang.org/x/net v0.47.0 // indirect
1821
golang.org/x/sys v0.38.0 // indirect
22+
golang.org/x/text v0.31.0 // indirect
1923
)

404-handler/go.sum

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ=
22
github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
3-
github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs=
4-
github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA=
5-
github.com/clipperhouse/uax29/v2 v2.3.0 h1:SNdx9DVUqMoBuBoW3iLOj4FQv3dN5mDtuqwuhIGpJy4=
6-
github.com/clipperhouse/uax29/v2 v2.3.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g=
7-
github.com/gofiber/fiber/v2 v2.52.10 h1:jRHROi2BuNti6NYXmZ6gbNSfT3zj/8c0xy94GOU5elY=
8-
github.com/gofiber/fiber/v2 v2.52.10/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw=
3+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
4+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5+
github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM=
6+
github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
7+
github.com/gofiber/fiber/v3 v3.0.0-rc.3 h1:h0KXuRHbivSslIpoHD1R/XjUsjcGwt+2vK0avFiYonA=
8+
github.com/gofiber/fiber/v3 v3.0.0-rc.3/go.mod h1:LNBPuS/rGoUFlOyy03fXsWAeWfdGoT1QytwjRVNSVWo=
9+
github.com/gofiber/schema v1.6.0 h1:rAgVDFwhndtC+hgV7Vu5ItQCn7eC2mBA4Eu1/ZTiEYY=
10+
github.com/gofiber/schema v1.6.0/go.mod h1:WNZWpQx8LlPSK7ZaX0OqOh+nQo/eW2OevsXs1VZfs/s=
11+
github.com/gofiber/utils/v2 v2.0.0-rc.2 h1:NvJTf7yMafTq16lUOJv70nr+HIOLNQcvGme/X+ftbW8=
12+
github.com/gofiber/utils/v2 v2.0.0-rc.2/go.mod h1:gXins5o7up+BQFiubmO8aUJc/+Mhd7EKXIiAK5GBomI=
913
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
1014
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
1115
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
@@ -14,14 +18,32 @@ github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHP
1418
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
1519
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
1620
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
17-
github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
18-
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
21+
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
22+
github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
23+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
24+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
25+
github.com/shamaton/msgpack/v2 v2.4.0 h1:O5Z08MRmbo0lA9o2xnQ4TXx6teJbPqEurqcCOQ8Oi/4=
26+
github.com/shamaton/msgpack/v2 v2.4.0/go.mod h1:6khjYnkx73f7VQU7wjcFS9DFjs+59naVWJv1TB7qdOI=
27+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
28+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
29+
github.com/tinylib/msgp v1.5.0 h1:GWnqAE54wmnlFazjq2+vgr736Akg58iiHImh+kPY2pc=
30+
github.com/tinylib/msgp v1.5.0/go.mod h1:cvjFkb4RiC8qSBOPMGPSzSAx47nAsfhLVTCZZNuHv5o=
1931
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
2032
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
2133
github.com/valyala/fasthttp v1.68.0 h1:v12Nx16iepr8r9ySOwqI+5RBJ/DqTxhOy1HrHoDFnok=
2234
github.com/valyala/fasthttp v1.68.0/go.mod h1:5EXiRfYQAoiO/khu4oU9VISC/eVY6JqmSpPJoHCKsz4=
35+
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
36+
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
2337
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
2438
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
39+
golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU=
40+
golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc=
41+
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
42+
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
2543
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
2644
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
2745
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
46+
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
47+
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
48+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
49+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

404-handler/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package main
77
import (
88
"log"
99

10-
"github.com/gofiber/fiber/v2"
10+
"github.com/gofiber/fiber/v3"
1111
)
1212

1313
func main() {
@@ -18,7 +18,7 @@ func main() {
1818
app.Get("/hello", hello)
1919

2020
// 404 Handler
21-
app.Use(func(c *fiber.Ctx) error {
21+
app.Use(func(c fiber.Ctx) error {
2222
return c.SendStatus(404) // => 404 "Not Found"
2323
})
2424

@@ -27,6 +27,6 @@ func main() {
2727
}
2828

2929
// Handler
30-
func hello(c *fiber.Ctx) error {
30+
func hello(c fiber.Ctx) error {
3131
return c.SendString("I made a ☕ for you!")
3232
}

air/go.mod

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@ module main
22

33
go 1.25.0
44

5-
require github.com/gofiber/fiber/v2 v2.52.10
5+
require github.com/gofiber/fiber/v3 v3.0.0-rc.3
66

77
require (
88
github.com/andybalholm/brotli v1.2.0 // indirect
9-
github.com/clipperhouse/stringish v0.1.1 // indirect
10-
github.com/clipperhouse/uax29/v2 v2.3.0 // indirect
9+
github.com/gofiber/schema v1.6.0 // indirect
10+
github.com/gofiber/utils/v2 v2.0.0-rc.2 // indirect
1111
github.com/google/uuid v1.6.0 // indirect
1212
github.com/klauspost/compress v1.18.1 // indirect
1313
github.com/mattn/go-colorable v0.1.14 // indirect
1414
github.com/mattn/go-isatty v0.0.20 // indirect
15-
github.com/mattn/go-runewidth v0.0.19 // indirect
15+
github.com/philhofer/fwd v1.2.0 // indirect
16+
github.com/tinylib/msgp v1.5.0 // indirect
1617
github.com/valyala/bytebufferpool v1.0.0 // indirect
1718
github.com/valyala/fasthttp v1.68.0 // indirect
19+
golang.org/x/crypto v0.44.0 // indirect
20+
golang.org/x/net v0.47.0 // indirect
1821
golang.org/x/sys v0.38.0 // indirect
22+
golang.org/x/text v0.31.0 // indirect
1923
)

0 commit comments

Comments
 (0)