cleanup: gofmt the 15 Go files main had unformatted — whitespace, comment alignment and three one-line funcs gofmt opens up; nothing else. go build and vet -tags nogui pass.

This commit is contained in:
yetone committed 2026-10-06 07:43:47 +08:00
1 parent 237d216b52
commit 9abfbff607
15 files changed
+21 -18

No files matched your search

+1 -1
View File
@@ -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 {
+2 -2
View File
@@ -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)
+1 -1
View File
@@ -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)
}
}
}
+1 -1
View File
@@ -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} {
+1 -1
View File
@@ -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())
})
+1 -1
View File
@@ -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
}
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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")
+3 -1
View File
@@ -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.
+2 -2
View File
@@ -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)
}
+1 -1
View File
@@ -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"
-1
View File
@@ -382,4 +382,3 @@ func zhipuTeamOf(key string) (org, project string) {
}
return "", ""
}
+3 -1
View File
@@ -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":
+2 -2
View File
@@ -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"`
+1 -1
View File
@@ -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)