mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
fix(lint): 修复 golangci-lint errcheck 与 gofmt 报错
- gateway_service.go buildStableSessionSeed: strings.Builder.WriteString 返回值用 _, _ = 显式忽略(errcheck) - openai_codex_transform_additions_test.go: client_metadata 类型断言改为 双值形式 cm3, _ := ...(errcheck check-type-assertions) - openai_gateway_service.go: codexCLIUserAgent 常量单独成组,收敛 = 前多余 空格对齐(gofmt)
This commit is contained in:
@@ -1436,11 +1436,11 @@ func (s *GatewayService) buildOAuthMetadataUserIDFromBody(
|
||||
// accountID 恒存在,故 seed 永不为空 —— 输出始终是确定性 UUID,而非随机值。
|
||||
func buildStableSessionSeed(accountID int64, clientDiscriminator, firstUserText string) string {
|
||||
var b strings.Builder
|
||||
b.WriteString(strconv.FormatInt(accountID, 10))
|
||||
b.WriteString("::")
|
||||
b.WriteString(clientDiscriminator)
|
||||
b.WriteString("::")
|
||||
b.WriteString(firstUserText)
|
||||
_, _ = b.WriteString(strconv.FormatInt(accountID, 10))
|
||||
_, _ = b.WriteString("::")
|
||||
_, _ = b.WriteString(clientDiscriminator)
|
||||
_, _ = b.WriteString("::")
|
||||
_, _ = b.WriteString(firstUserText)
|
||||
return b.String()
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ func TestApplyCodexClientMetadata(t *testing.T) {
|
||||
// 既有 client_metadata(如 turn metadata)保留,仅补 installation 键
|
||||
body3 := map[string]any{"client_metadata": map[string]any{"x-codex-turn-metadata": "t"}}
|
||||
require.True(t, applyCodexClientMetadata(body3, acc))
|
||||
cm3 := body3["client_metadata"].(map[string]any)
|
||||
cm3, _ := body3["client_metadata"].(map[string]any)
|
||||
require.Equal(t, "t", cm3["x-codex-turn-metadata"])
|
||||
require.Equal(t, "dev-xyz", cm3["x-codex-installation-id"])
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ const (
|
||||
// 与真实 Codex CLI 的 User-Agent 结构对齐:
|
||||
// {originator}/{version} ({OS} {OS_version}; {arch}) {terminal}
|
||||
// 旧值 "codex_cli_rs/0.125.0" 缺少 OS/架构/终端后缀,易被上游指纹识别为非官方客户端。
|
||||
codexCLIUserAgent = "codex_cli_rs/0.125.0 (Ubuntu 22.4.0; x86_64) xterm-256color"
|
||||
codexCLIUserAgent = "codex_cli_rs/0.125.0 (Ubuntu 22.4.0; x86_64) xterm-256color"
|
||||
// codex_cli_only 拒绝时单个请求头日志长度上限(字符)
|
||||
codexCLIOnlyHeaderValueMaxBytes = 256
|
||||
|
||||
|
||||
Reference in New Issue
Block a user