chore(deps): update Go dependencies

- Update all dependencies to latest versions

- Upgrade touka to break/v1 branch

- Migrate from RunShutdown to Run with graceful shutdown options

- Use functional options pattern: WithAddr and WithGracefulShutdownDefault
This commit is contained in:
wjqserver 2026-04-11 22:34:32 +08:00
parent 32baca85db
commit 3d01d4cd15
7 changed files with 51 additions and 46 deletions

View file

@ -72,7 +72,7 @@ func newProxyDial(proxyUrls string) proxy.Dialer {
var proxyDialer proxy.Dialer = proxy.Direct // 初始为直接连接,不使用代理
// 支持多个代理 URL以逗号分隔
for _, proxyUrl := range strings.Split(proxyUrls, ",") {
for proxyUrl := range strings.SplitSeq(proxyUrls, ",") {
proxyUrl = strings.TrimSpace(proxyUrl) // 去除首尾空格
if proxyUrl == "" { // 跳过空的代理 URL
continue

View file

@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"io"
"net/http"
"net/url"
"strconv"
@ -12,7 +13,6 @@ import (
"ghproxy/config"
"ghproxy/weakcache"
"github.com/WJQSERVER-STUDIO/go-utils/iox"
"github.com/WJQSERVER-STUDIO/go-utils/limitreader"
"github.com/go-json-experiment/json"
"github.com/infinite-iroha/touka"
@ -363,7 +363,7 @@ func GhcrRequest(ctx context.Context, c *touka.Context, u string, image *imageIn
// 如果最终响应是 404, 则读取响应体并返回自定义错误页面
if resp.StatusCode == 404 {
defer resp.Body.Close() // 使用defer确保在函数返回前关闭响应体
bodyBytes, err := iox.ReadAll(resp.Body)
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
c.Warnf("Failed to read upstream 404 response body: %v", err)
} else {
@ -481,7 +481,7 @@ func ChallengeReq(target string, image *imageInfo, ctx context.Context, c *touka
defer authResp.Body.Close() // 确保响应体关闭
// 读取认证响应体
bodyBytes, err := iox.ReadAll(authResp.Body)
bodyBytes, err := io.ReadAll(authResp.Body)
if err != nil {
c.Errorf("Failed to read auth response body: %v", err)
return

View file

@ -289,7 +289,7 @@ func getParsedTemplate() (*template.Template, error) {
}
// htmlTemplateRender 修改为使用缓存的模板。
func htmlTemplateRender(data interface{}) ([]byte, error) {
func htmlTemplateRender(data any) ([]byte, error) {
tmpl, err := getParsedTemplate()
if err != nil {
return nil, fmt.Errorf("failed to get parsed template: %w", err)