From 9abfbff6073ab33bb2c2e8e0692c35dc0be411b5 Mon Sep 17 00:00:00 2001 From: yetone Date: Tue, 6 Oct 2026 07:43:47 +0800 Subject: [PATCH] =?UTF-8?q?cleanup:=20gofmt=20the=2015=20Go=20files=20main?= =?UTF-8?q?=20had=20unformatted=20=E2=80=94=20whitespace,=20comment=20alig?= =?UTF-8?q?nment=20and=20three=20one-line=20funcs=20gofmt=20opens=20up;=20?= =?UTF-8?q?nothing=20else.=20go=20build=20and=20vet=20-tags=20nogui=20pass?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/gateway/codex_titles_test.go | 2 +- internal/gateway/limit_test.go | 4 ++-- internal/gateway/responses_only_draw_test.go | 2 +- internal/gateway/stream_error_open_test.go | 2 +- internal/gui/api.go | 2 +- internal/gui/sessions.go | 2 +- internal/gui/settings_keep_test.go | 2 +- internal/library/own_skill_test.go | 2 +- internal/provider/cline_usage.go | 4 +++- internal/provider/qianfan_test.go | 4 ++-- internal/provider/zcode_client.go | 2 +- internal/provider/zcode_team.go | 1 - internal/provider/zcode_team_test.go | 4 +++- internal/sessions/sessions.go | 4 ++-- quota_history_cli_test.go | 2 +- 15 files changed, 21 insertions(+), 18 deletions(-) diff --git a/internal/gateway/codex_titles_test.go b/internal/gateway/codex_titles_test.go index 0733cc12..87b4d206 100644 --- a/internal/gateway/codex_titles_test.go +++ b/internal/gateway/codex_titles_test.go @@ -275,7 +275,7 @@ func TestTitleJSONFillsTheSchema(t *testing.T) { for in, want := range map[string]string{ "Fix login bug": `{"description":"Fix login bug","title":"Fix login bug"}`, `{"title":"Fix login","description":"The login form rejects valid passwords"}`: `{"description":"The login form rejects valid passwords","title":"Fix login"}`, - "Fix the login bug that rejects every valid password on mobile": `{"description":"Fix the login bug that rejects every valid password on mobile","title":"Fix the login bug that rejects every"}`, + "Fix the login bug that rejects every valid password on mobile": `{"description":"Fix the login bug that rejects every valid password on mobile","title":"Fix the login bug that rejects every"}`, "": "", } { if got := titleJSON(in, shape); got != want { diff --git a/internal/gateway/limit_test.go b/internal/gateway/limit_test.go index f46421ce..9016b3be 100644 --- a/internal/gateway/limit_test.go +++ b/internal/gateway/limit_test.go @@ -90,8 +90,8 @@ func TestTooFewTokensSaidWithSigns(t *testing.T) { var asked []int up := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var q struct { - MaxTokens int `json:"max_tokens"` - MaxCompletionTokens int `json:"max_completion_tokens"` + MaxTokens int `json:"max_tokens"` + MaxCompletionTokens int `json:"max_completion_tokens"` Stream bool `json:"stream"` } b, _ := io.ReadAll(r.Body) diff --git a/internal/gateway/responses_only_draw_test.go b/internal/gateway/responses_only_draw_test.go index f2ae9c4f..b3bc1c7f 100644 --- a/internal/gateway/responses_only_draw_test.go +++ b/internal/gateway/responses_only_draw_test.go @@ -65,4 +65,4 @@ func TestResponsesOnlyProviderDraws(t *testing.T) { if len(paths) != 1 || paths[0] != "/v1/images/generations" || !strings.Contains(bodies[0], `"model":"gpt-image-2.5-flare"`) { t.Fatalf("asked %v %v", paths, bodies) } -} \ No newline at end of file +} diff --git a/internal/gateway/stream_error_open_test.go b/internal/gateway/stream_error_open_test.go index 18beb090..fca3d104 100644 --- a/internal/gateway/stream_error_open_test.go +++ b/internal/gateway/stream_error_open_test.go @@ -30,7 +30,7 @@ func TestStreamErrorKeptOpenFailsOverAtOnce(t *testing.T) { `data: {"error":{"code":429,"type":"rate_limit_error","message":"rate limited"}}`), provider.Responses: sse(`event: response.created`+"\n"+`data: {"type":"response.created","response":{"id":"resp_1","status":"in_progress","output":[]}}`, `event: response.failed`+"\n"+`data: {"type":"response.failed","response":{"status":"failed","error":{"code":"rate_limit_exceeded","message":"rate limited"}}}`), - provider.Anthropic: sse(`event: error`+"\n"+`data: {"type":"error","error":{"type":"rate_limit_error","message":"rate limited"}}`), + provider.Anthropic: sse(`event: error` + "\n" + `data: {"type":"error","error":{"type":"rate_limit_error","message":"rate limited"}}`), } for _, proto := range provider.Protocols { for _, both := range []bool{false, true} { diff --git a/internal/gui/api.go b/internal/gui/api.go index 00922662..61932e59 100644 --- a/internal/gui/api.go +++ b/internal/gui/api.go @@ -930,7 +930,7 @@ func Handler(w Windows, gw *gateway.Server) http.Handler { cliBehindRoutes(mux) gatewayFixRoutes(mux) gatewayModeRoutes(mux) - mux.HandleFunc("GET /api/settings",func(rw http.ResponseWriter, r *http.Request) { + mux.HandleFunc("GET /api/settings", func(rw http.ResponseWriter, r *http.Request) { access.MigrateLegacyLANKeyBestEffort() writeJSON(rw, settingsState()) }) diff --git a/internal/gui/sessions.go b/internal/gui/sessions.go index 0b2c6c32..64ce793e 100644 --- a/internal/gui/sessions.go +++ b/internal/gui/sessions.go @@ -175,7 +175,7 @@ func sessionRoutes(mux *http.ServeMux, w Windows) { fail(rw, errors.New("no such session")) return } - if err := openTerminal(run,settings.Load().SessionTerminal); err != nil { + if err := openTerminal(run, settings.Load().SessionTerminal); err != nil { fail(rw, err) return } diff --git a/internal/gui/settings_keep_test.go b/internal/gui/settings_keep_test.go index 935fae0a..f4706ca9 100644 --- a/internal/gui/settings_keep_test.go +++ b/internal/gui/settings_keep_test.go @@ -128,7 +128,7 @@ func TestSettingsSaveKeepsWhatItDoesNotSend(t *testing.T) { LANKey: "sk-lan", LANKeyID: "lan-key-id", Port: 3591, - GitHubToken: "ghp_kept", + GitHubToken: "ghp_kept", RequestArchive: true, RequestArchiveMaxMB: 64, QuotaLeft: true, diff --git a/internal/library/own_skill_test.go b/internal/library/own_skill_test.go index 935c7ac5..0af42551 100644 --- a/internal/library/own_skill_test.go +++ b/internal/library/own_skill_test.go @@ -21,7 +21,7 @@ func TestOwnSkillInTheWay(t *testing.T) { codex := filepath.Join(h, ".codex/skills/impeccable") gemini := filepath.Join(h, ".gemini/skills/impeccable") skill(t, claude, "impeccable", "Design") - skill(t, codex, "impeccable", "Design") // a byte copy + skill(t, codex, "impeccable", "Design") // a byte copy skill(t, gemini, "impeccable", "Old design") // another write(t, filepath.Join(codex, ".DS_Store"), "finder") skill(t, filepath.Join(h, ".claude/skills/notes"), "notes", "Mine") diff --git a/internal/provider/cline_usage.go b/internal/provider/cline_usage.go index bdb73fd5..25767025 100644 --- a/internal/provider/cline_usage.go +++ b/internal/provider/cline_usage.go @@ -126,7 +126,9 @@ func clineUSD(n float64) string { // clineStatus is an HTTP status the Cline API answered with. type clineStatus int -func (s clineStatus) Error() string { return fmt.Sprintf("Cline answered %d %s", int(s), http.StatusText(int(s))) } +func (s clineStatus) Error() string { + return fmt.Sprintf("Cline answered %d %s", int(s), http.StatusText(int(s))) +} // clineGet asks the Cline API at path with the key and reads its // {success, data} reply's data into out. diff --git a/internal/provider/qianfan_test.go b/internal/provider/qianfan_test.go index a9c901fd..2c9cfbfe 100644 --- a/internal/provider/qianfan_test.go +++ b/internal/provider/qianfan_test.go @@ -114,7 +114,7 @@ func TestQianfanPlansListNothing(t *testing.T) { plan := base plan.Chat, plan.Responses = srv.URL+"/v2/tokenplan/personal", srv.URL+"/v2/tokenplan/personal" - plan.Anthropic = srv.URL+"/anthropic/tokenplan/personal" + plan.Anthropic = srv.URL + "/anthropic/tokenplan/personal" ms, err := plan.Fetch(context.Background()) if err != nil { t.Fatalf("plan fetch: %v", err) @@ -125,7 +125,7 @@ func TestQianfanPlansListNothing(t *testing.T) { api := base api.Chat, api.Responses = srv.URL+"/v2", srv.URL+"/v2" - api.Anthropic = srv.URL+"/anthropic" + api.Anthropic = srv.URL + "/anthropic" if ms, err := api.Fetch(context.Background()); err != nil || len(ms) != 3 || atomic.LoadInt32(&asked) == 0 { t.Fatalf("pay as you go: %d models, %d requests, err %v", len(ms), asked, err) } diff --git a/internal/provider/zcode_client.go b/internal/provider/zcode_client.go index ffc3321b..9da79cde 100644 --- a/internal/provider/zcode_client.go +++ b/internal/provider/zcode_client.go @@ -25,8 +25,8 @@ package provider // Plan, and every other provider, get the agent's request as it is. import ( - _ "embed" "bytes" + _ "embed" "encoding/json" "os" "path/filepath" diff --git a/internal/provider/zcode_team.go b/internal/provider/zcode_team.go index b5c1d5fb..0f9f1197 100644 --- a/internal/provider/zcode_team.go +++ b/internal/provider/zcode_team.go @@ -382,4 +382,3 @@ func zhipuTeamOf(key string) (org, project string) { } return "", "" } - diff --git a/internal/provider/zcode_team_test.go b/internal/provider/zcode_team_test.go index f1feab3a..17335102 100644 --- a/internal/provider/zcode_team_test.go +++ b/internal/provider/zcode_team_test.go @@ -34,7 +34,9 @@ func newZCodeTeamUpstream(t *testing.T) *zcodeTeamUpstream { u.srv = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { auth := r.Header.Get("Authorization") org, proj := r.Header.Get("Bigmodel-Organization"), r.Header.Get("Bigmodel-Project") - ok := func(data any) { json.NewEncoder(w).Encode(map[string]any{"code": 200, "msg": "ok", "data": data, "success": true}) } + ok := func(data any) { + json.NewEncoder(w).Encode(map[string]any{"code": 200, "msg": "ok", "data": data, "success": true}) + } deny := func() { w.WriteHeader(401) } switch p := r.URL.Path; { case p == "/api/v1/oauth/cli/init": diff --git a/internal/sessions/sessions.go b/internal/sessions/sessions.go index 00dc23ee..9a8a2435 100644 --- a/internal/sessions/sessions.go +++ b/internal/sessions/sessions.go @@ -138,9 +138,9 @@ type state struct { ID string `json:"id,omitempty"` Cwd string `json:"cwd,omitempty"` Title string `json:"title,omitempty"` - Named string `json:"named,omitempty"` // the agent's own title for it + Named string `json:"named,omitempty"` // the agent's own title for it Custom string `json:"custom,omitempty"` // the name the user gave it - First string `json:"first,omitempty"` // the first message, when no prompt looked typed + First string `json:"first,omitempty"` // the first message, when no prompt looked typed Start time.Time `json:"start"` Last time.Time `json:"last"` Models map[string]Tokens `json:"models,omitempty"` diff --git a/quota_history_cli_test.go b/quota_history_cli_test.go index 24c01ae8..36ae3b7d 100644 --- a/quota_history_cli_test.go +++ b/quota_history_cli_test.go @@ -40,7 +40,7 @@ func TestQuotaHistoryCmd(t *testing.T) { return provider.QuotaPoint{At: now.Add(-ago), Left: left, ResetsAt: &r} } h := map[string]map[string][]provider.QuotaPoint{ - "codex|a@x.com": {"5 hours": {pt(30*time.Hour, 40, now.Add(-26*time.Hour)), pt(3*time.Hour, 100, reset), pt(time.Hour, 72.5, reset)}}, + "codex|a@x.com": {"5 hours": {pt(30*time.Hour, 40, now.Add(-26*time.Hour)), pt(3*time.Hour, 100, reset), pt(time.Hour, 72.5, reset)}}, "claude|b@x.com": {"Weekly": {pt(2*time.Hour, 55, now.Add(72*time.Hour))}}, } b, _ := json.Marshal(h)