From d292407ec8163929aaddfd347eb4576cc4ff4d45 Mon Sep 17 00:00:00 2001 From: Jean Machuca Date: Fri, 3 Jul 2026 20:39:49 +0000 Subject: [PATCH 1/7] fix: correct -llama to -lllama, add missing include/lib paths, fix CI with CGO_ENABLED=0, bump golangci to v9 --- .github/workflows/ci.yml | 4 ++-- internal/llm/bridge.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9257e1d..05698a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,10 +16,10 @@ jobs: go-version: "1.23" - name: Build - run: go build -o /dev/null ./cmd/coginfer + run: CGO_ENABLED=0 go build -o /dev/null ./cmd/coginfer - name: Lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v9 with: version: latest args: --timeout=3m diff --git a/internal/llm/bridge.go b/internal/llm/bridge.go index f3a9a9c..16aba51 100644 --- a/internal/llm/bridge.go +++ b/internal/llm/bridge.go @@ -3,8 +3,8 @@ package llm /* -#cgo LDFLAGS: -L${SRCDIR}/../../vendor/llama.cpp/build -llama -lm -lstdc++ -#cgo CFLAGS: -I${SRCDIR}/../../vendor/llama.cpp/include +#cgo LDFLAGS: -L${SRCDIR}/../../vendor/llama.cpp/build -L${SRCDIR}/../../vendor/llama.cpp/build/src -lllama -lm -lstdc++ +#cgo CFLAGS: -I${SRCDIR}/../../vendor/llama.cpp/include -I${SRCDIR}/../../vendor/llama.cpp/ggml/include #include #include "llama.h" From 488987c10d85d91d3bb075f23fb3d2a5bb3dc144 Mon Sep 17 00:00:00 2001 From: Jean Machuca Date: Fri, 3 Jul 2026 20:49:33 +0000 Subject: [PATCH 2/7] docs: correct submodule claim, update CGo build flags and CI docs --- AGENTS.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 7cb5398..282c5aa 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -20,7 +20,7 @@ internal/llm/ — Backend interface + implementations ├── cgobackend.go — CgoBackend: Backend impl calling bridge functions (build tag: cgo) └── loadopts.go — LoadOptions{NumCtx, GPULayers, Threads} internal/model/ — Model scanning and metadata (.gguf file discovery) -vendor/llama.cpp/ — Git submodule, pinned to b9842 +vendor/llama.cpp/ — Manually cloned (NOT a git submodule — no `.gitmodules` file) ``` ### coginfer (Wide Model) @@ -30,18 +30,27 @@ LLM inference server linking llama.cpp via a vendored CGo bridge, exposing an Ol #### Build ```bash -# With CGo (production — requires cmake + gcc + submodule) +# With CGo (production — requires cmake + gcc + llama.cpp cloned into vendor/) cd vendor/llama.cpp && cmake -B build -DLLAMA_NO_ACCELERATE=1 \ -DLLAMA_STATIC=1 -DLLAMA_NATIVE=0 \ -DBUILD_SHARED_LIBS=0 -DLLAMA_BUILD_TESTS=0 \ - -DLLAMA_BUILD_EXAMPLES=0 -DLLAMA_BUILD_SERVER=0 -cmake --build build --config Release -j$(nproc) + -DLLAMA_BUILD_EXAMPLES=0 -DLLAMA_BUILD_SERVER=0 \ + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY="$PWD/build" +cmake --build build --target llama --config Release -j$(nproc) cd ../.. && CGO_ENABLED=1 go build -tags=cgo -o bin/coginfer ./cmd/coginfer # Without CGo (CI, development — mock backend only) CGO_ENABLED=0 go build -o bin/coginfer ./cmd/coginfer ``` +**CGo flags** (in `internal/llm/bridge.go`): +- `-lllama` — NOT `-llama` (cmake target `llama` → `libllama.a`) +- `-L.../build/src` — modern llama.cpp puts static archives in `build/src/` + (workaround: `CMAKE_ARCHIVE_OUTPUT_DIRECTORY` puts it in `build/`) +- `-I.../ggml/include` — `llama.h` includes `ggml.h`, `ggml-cpu.h`, etc. +- `CGO_LDFLAGS` is appended **before** `#cgo LDFLAGS` by Go toolchain; + `-L` in env var establishes search path before `-l` in source + #### Usage ```bash @@ -51,9 +60,6 @@ CGO_ENABLED=0 go build -o bin/coginfer ./cmd/coginfer # Start with CGo llama.cpp bridge (production) ./bin/coginfer --backend cgo --models /cognitiveos/models -# Start with CGo llama.cpp bridge (production) -./bin/coginfer --backend cgo --models /cognitiveos/models - # Custom port and log file ./bin/coginfer --addr 127.0.0.1:11434 --log /cognitiveos/logs/inference.log ``` @@ -77,13 +83,12 @@ CGO_ENABLED=0 go build -o bin/coginfer ./cmd/coginfer - **mock**: Simulated token generation with delays, no external dependencies. Default for development. Always available. - **cgo**: In-process llama.cpp via CGo bridge. Requires `CGO_ENABLED=1` and `vendor/llama.cpp/build/libllama.a`. Production default. -- **cgo**: In-process llama.cpp via CGo bridge. Requires `CGO_ENABLED=1` and `vendor/llama.cpp/build/libllama.a`. Production default. #### Build Tags - `bridge.go`, `cgobackend.go`, `backend_cgo.go` — `//go:build cgo` - `backend_stub.go` — `//go:build !cgo` -- CI runs `CGO_ENABLED=0`, excludes all CGo files automatically +- CI runs `CGO_ENABLED=0` (Ubuntu defaults to `CGO_ENABLED=1`, which includes `cgo` tag — must be explicit) - `MockBackend` has no build tag — always available ### cograw (Raw Model — Firmware Guardrail) From e4900633f459cdb413f69bd2d72dedd8d263c3ca Mon Sep 17 00:00:00 2001 From: Jean Machuca Date: Fri, 3 Jul 2026 21:00:15 +0000 Subject: [PATCH 3/7] fix: set CGO_ENABLED=0 for lint step (llama.h not available in CI) --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05698a5..a8e8ebf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,8 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v9 + env: + CGO_ENABLED: 0 with: version: latest args: --timeout=3m From 9d60a9be7293eeb310af1ffb0a7ac0e2b6f1b6f0 Mon Sep 17 00:00:00 2001 From: Jean Machuca Date: Fri, 3 Jul 2026 21:03:11 +0000 Subject: [PATCH 4/7] fix: resolve all golangci-lint errcheck, staticcheck, and unused issues --- cmd/cograw/main.go | 5 +---- internal/llm/llm_test.go | 2 +- internal/model/model.go | 2 +- internal/model/model_test.go | 8 ++++---- internal/server/server.go | 12 ++++++------ internal/server/server_test.go | 12 ++++++------ 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/cmd/cograw/main.go b/cmd/cograw/main.go index 686fadc..94ca598 100644 --- a/cmd/cograw/main.go +++ b/cmd/cograw/main.go @@ -519,10 +519,7 @@ func handleAudit(call RPCCall, rm *RawModel) RPCResp { totalMB, freeMB := readMemAvailableMB() - allowed := true - if params.RequestedMB > 0 && params.RequestedMB > freeMB { - allowed = false - } + allowed := params.RequestedMB <= 0 || params.RequestedMB <= freeMB return RPCResp{ JSONRPC: "2.0", diff --git a/internal/llm/llm_test.go b/internal/llm/llm_test.go index 5dfb317..33e376a 100644 --- a/internal/llm/llm_test.go +++ b/internal/llm/llm_test.go @@ -57,7 +57,7 @@ func TestMockBackendGenerateWithoutLoad(t *testing.T) { func TestMockBackendGenerate(t *testing.T) { b := NewMockBackend() - b.Load("/cognitiveos/models/test.gguf", nil) + _ = b.Load("/cognitiveos/models/test.gguf", nil) resp, err := b.Generate(GenerateReq{Prompt: "What is 2+2?"}, nil) if err != nil { diff --git a/internal/model/model.go b/internal/model/model.go index 9c9ae93..804273c 100644 --- a/internal/model/model.go +++ b/internal/model/model.go @@ -97,7 +97,7 @@ func (m *Manager) Resolve(name string) (string, error) { // Search recursively var found string - filepath.Walk(m.ModelDir, func(path string, info os.FileInfo, err error) error { + _ = filepath.Walk(m.ModelDir, func(path string, info os.FileInfo, err error) error { if err != nil || found != "" { return nil } diff --git a/internal/model/model_test.go b/internal/model/model_test.go index 8e9c43f..3e3a725 100644 --- a/internal/model/model_test.go +++ b/internal/model/model_test.go @@ -9,7 +9,7 @@ import ( func TestManagerResolveAbsPath(t *testing.T) { dir := t.TempDir() modelPath := filepath.Join(dir, "test.gguf") - os.WriteFile(modelPath, []byte("dummy"), 0644) + _ = os.WriteFile(modelPath, []byte("dummy"), 0644) m := NewManager(dir) got, err := m.Resolve(modelPath) @@ -31,9 +31,9 @@ func TestManagerResolveNotFound(t *testing.T) { func TestManagerList(t *testing.T) { dir := t.TempDir() - os.MkdirAll(filepath.Join(dir, "wide", "active"), 0755) - os.WriteFile(filepath.Join(dir, "raw-model.gguf"), []byte("raw"), 0644) - os.WriteFile(filepath.Join(dir, "wide", "active", "gemma.gguf"), []byte("gemma"), 0644) + _ = os.MkdirAll(filepath.Join(dir, "wide", "active"), 0755) + _ = os.WriteFile(filepath.Join(dir, "raw-model.gguf"), []byte("raw"), 0644) + _ = os.WriteFile(filepath.Join(dir, "wide", "active", "gemma.gguf"), []byte("gemma"), 0644) m := NewManager(dir) models, err := m.List() diff --git a/internal/server/server.go b/internal/server/server.go index 7a75b57..6d721e3 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -231,7 +231,7 @@ func (s *Server) handleGenerate(w http.ResponseWriter, r *http.Request) { onToken := func(token string) { line, _ := json.Marshal(llm.GenerateResp{Response: token, Done: false}) - fmt.Fprintf(w, "%s\n", line) + _, _ = fmt.Fprintf(w, "%s\n", line) flusher.Flush() } @@ -242,7 +242,7 @@ func (s *Server) handleGenerate(w http.ResponseWriter, r *http.Request) { } resp.Done = true line, _ := json.Marshal(resp) - fmt.Fprintf(w, "%s\n", line) + _, _ = fmt.Fprintf(w, "%s\n", line) flusher.Flush() return } @@ -273,7 +273,7 @@ func (s *Server) handleChat(w http.ResponseWriter, r *http.Request) { var promptBuilder strings.Builder for _, msg := range req.Messages { - promptBuilder.WriteString(fmt.Sprintf("%s: %s\n", msg.Role, msg.Content)) + fmt.Fprintf(&promptBuilder, "%s: %s\n", msg.Role, msg.Content) } prompt := promptBuilder.String() @@ -312,7 +312,7 @@ func (s *Server) handleChat(w http.ResponseWriter, r *http.Request) { onToken := func(token string) { line, _ := json.Marshal(llm.GenerateResp{Response: token, Done: false}) - fmt.Fprintf(w, "%s\n", line) + _, _ = fmt.Fprintf(w, "%s\n", line) flusher.Flush() } @@ -323,7 +323,7 @@ func (s *Server) handleChat(w http.ResponseWriter, r *http.Request) { } resp.Done = true line, _ := json.Marshal(resp) - fmt.Fprintf(w, "%s\n", line) + _, _ = fmt.Fprintf(w, "%s\n", line) flusher.Flush() return } @@ -444,7 +444,7 @@ func (s *Server) handleDelete(w http.ResponseWriter, r *http.Request) { var req deleteRequest if r.Method == http.MethodPost { - json.NewDecoder(r.Body).Decode(&req) + _ = json.NewDecoder(r.Body).Decode(&req) } s.mu.Lock() diff --git a/internal/server/server_test.go b/internal/server/server_test.go index 03f88c9..b7e0d86 100644 --- a/internal/server/server_test.go +++ b/internal/server/server_test.go @@ -18,7 +18,7 @@ func startTestServer(t *testing.T) (*httptest.Server, string) { t.Helper() dir := t.TempDir() modelDir := filepath.Join(dir, "models") - os.MkdirAll(filepath.Join(modelDir, "wide", "active"), 0755) + _ = os.MkdirAll(filepath.Join(modelDir, "wide", "active"), 0755) os.WriteFile(filepath.Join(modelDir, "test-model.gguf"), []byte("dummy-model-data"), 0644) s := New(modelDir, "mock") @@ -40,7 +40,7 @@ func request(t *testing.T, url, method string, body interface{}) *http.Response t.Helper() var buf bytes.Buffer if body != nil { - json.NewEncoder(&buf).Encode(body) + _ = json.NewEncoder(&buf).Encode(body) } req, err := http.NewRequest(method, url, &buf) if err != nil { @@ -58,7 +58,7 @@ func request(t *testing.T, url, method string, body interface{}) *http.Response func bodyString(t *testing.T, resp *http.Response) string { t.Helper() - defer resp.Body.Close() + defer func() { _ = resp.Body.Close() }() b, _ := io.ReadAll(resp.Body) return strings.TrimSpace(string(b)) } @@ -69,7 +69,7 @@ func decodeMap(t *testing.T, resp *http.Response) testResp { if err := json.NewDecoder(resp.Body).Decode(&r); err != nil { t.Fatalf("decode: %v (body: %s)", err, bodyString(t, resp)) } - resp.Body.Close() + _ = resp.Body.Close() return r } @@ -81,7 +81,7 @@ func TestHealth(t *testing.T) { if resp.StatusCode != 200 { t.Fatalf("expected 200, got %d: %s", resp.StatusCode, bodyString(t, resp)) } - resp.Body.Close() + _ = resp.Body.Close() } func TestStatus(t *testing.T) { @@ -231,7 +231,7 @@ func TestGenerateStream(t *testing.T) { "stream": true, } var buf bytes.Buffer - json.NewEncoder(&buf).Encode(body) + _ = json.NewEncoder(&buf).Encode(body) req, err := http.NewRequest("POST", ts.URL+"/api/generate", &buf) if err != nil { From 7b6be86defb524332ff4b394794eaceb66d84371 Mon Sep 17 00:00:00 2001 From: Jean Machuca Date: Fri, 3 Jul 2026 21:05:41 +0000 Subject: [PATCH 5/7] fix: capture both return values from b.Load --- internal/llm/llm_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/llm/llm_test.go b/internal/llm/llm_test.go index 33e376a..d396124 100644 --- a/internal/llm/llm_test.go +++ b/internal/llm/llm_test.go @@ -57,7 +57,7 @@ func TestMockBackendGenerateWithoutLoad(t *testing.T) { func TestMockBackendGenerate(t *testing.T) { b := NewMockBackend() - _ = b.Load("/cognitiveos/models/test.gguf", nil) + _, _ = b.Load("/cognitiveos/models/test.gguf", nil) resp, err := b.Generate(GenerateReq{Prompt: "What is 2+2?"}, nil) if err != nil { From 73880364be5c53dc8200461a000bc9ee52e647e3 Mon Sep 17 00:00:00 2001 From: Jean Machuca Date: Fri, 3 Jul 2026 21:11:35 +0000 Subject: [PATCH 6/7] fix: resolve all remaining golangci-lint errcheck issues --- cmd/coginfer/main.go | 2 +- cmd/cograw/main.go | 18 +++++++++--------- internal/llm/cgobackend.go | 4 ++-- internal/llm/llm_test.go | 6 +++--- internal/server/server_test.go | 22 +++++++++++----------- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/cmd/coginfer/main.go b/cmd/coginfer/main.go index 1683126..2b890f4 100644 --- a/cmd/coginfer/main.go +++ b/cmd/coginfer/main.go @@ -20,7 +20,7 @@ func main() { if err != nil { log.Fatal(err) } - defer f.Close() + defer func() { _ = f.Close() }() log.SetOutput(f) } diff --git a/cmd/cograw/main.go b/cmd/cograw/main.go index 94ca598..ce496e8 100644 --- a/cmd/cograw/main.go +++ b/cmd/cograw/main.go @@ -181,7 +181,7 @@ var rawLog *log.Logger func initRawLog(path string) { dir := filepath.Dir(path) - os.MkdirAll(dir, 0755) + _ = os.MkdirAll(dir, 0755) f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0640) if err != nil { log.Printf("WARN: cannot open raw audit log %s: %v", path, err) @@ -215,7 +215,7 @@ func main() { if err != nil { log.Fatal(err) } - defer f.Close() + defer func() { _ = f.Close() }() log.SetOutput(f) } @@ -227,7 +227,7 @@ func main() { } logAudit("startup", fmt.Sprintf("raw model loaded: %s", *modelPath)) - os.Remove(*socketPath) + _ = os.Remove(*socketPath) addr, err := net.ResolveUnixAddr("unix", *socketPath) if err != nil { log.Fatalf("resolve addr: %v", err) @@ -240,7 +240,7 @@ func main() { if err := os.Chmod(*socketPath, 0600); err != nil { log.Fatalf("chmod: %v", err) } - defer os.Remove(*socketPath) + defer func() { _ = os.Remove(*socketPath) }() log.Printf("cograw ready on %s (model: %s)", *socketPath, rm.model) @@ -250,7 +250,7 @@ func main() { go func() { <-sigCh log.Println("shutting down") - listener.Close() + _ = listener.Close() }() for { @@ -283,7 +283,7 @@ func (r *RawModel) verifyModel(path string) error { } func handleConn(conn *net.UnixConn, rm *RawModel) { - defer conn.Close() + defer func() { _ = conn.Close() }() decoder := json.NewDecoder(conn) encoder := json.NewEncoder(conn) @@ -295,7 +295,7 @@ func handleConn(conn *net.UnixConn, rm *RawModel) { } resp := dispatch(call, rm) - encoder.Encode(resp) + _ = encoder.Encode(resp) } } @@ -499,12 +499,12 @@ func readMemAvailableMB() (int64, int64) { for _, line := range lines { if strings.HasPrefix(line, "MemTotal:") { var kb int64 - fmt.Sscanf(line, "MemTotal: %d kB", &kb) + _, _ = fmt.Sscanf(line, "MemTotal: %d kB", &kb) totalMB = kb / 1024 } if strings.HasPrefix(line, "MemAvailable:") { var kb int64 - fmt.Sscanf(line, "MemAvailable: %d kB", &kb) + _, _ = fmt.Sscanf(line, "MemAvailable: %d kB", &kb) availableMB = kb / 1024 } } diff --git a/internal/llm/cgobackend.go b/internal/llm/cgobackend.go index 3d59a82..f76fc4d 100644 --- a/internal/llm/cgobackend.go +++ b/internal/llm/cgobackend.go @@ -63,8 +63,8 @@ func (c *CgoBackend) Load(modelPath string, opts *LoadOptions) (*ModelInfo, erro return nil, fmt.Errorf("E_MODEL_NOT_FOUND: %s: %w", modelPath, err) } magic := make([]byte, 4) - f.Read(magic) - f.Close() + _, _ = f.Read(magic) + _ = f.Close() if string(magic) != "GGUF" { return nil, fmt.Errorf("E_MODEL_LOAD_FAILED: invalid GGUF magic bytes in %s", modelPath) } diff --git a/internal/llm/llm_test.go b/internal/llm/llm_test.go index d396124..4f7a444 100644 --- a/internal/llm/llm_test.go +++ b/internal/llm/llm_test.go @@ -27,7 +27,7 @@ func TestMockBackendLoad(t *testing.T) { func TestMockBackendUnload(t *testing.T) { b := NewMockBackend() - b.Load("/cognitiveos/models/test.gguf", nil) + _, _ = b.Load("/cognitiveos/models/test.gguf", nil) if err := b.Unload(); err != nil { t.Fatalf("unload: %v", err) } @@ -38,7 +38,7 @@ func TestMockBackendUnload(t *testing.T) { func TestMockBackendClose(t *testing.T) { b := NewMockBackend() - b.Load("/cognitiveos/models/test.gguf", nil) + _, _ = b.Load("/cognitiveos/models/test.gguf", nil) if err := b.Close(); err != nil { t.Fatalf("close: %v", err) } @@ -79,7 +79,7 @@ func TestMockBackendGenerate(t *testing.T) { func TestMockBackendGenerateStreaming(t *testing.T) { b := NewMockBackend() - b.Load("/cognitiveos/models/test.gguf", nil) + _, _ = b.Load("/cognitiveos/models/test.gguf", nil) var tokens []string onToken := func(tok string) { diff --git a/internal/server/server_test.go b/internal/server/server_test.go index b7e0d86..1eb117d 100644 --- a/internal/server/server_test.go +++ b/internal/server/server_test.go @@ -19,7 +19,7 @@ func startTestServer(t *testing.T) (*httptest.Server, string) { dir := t.TempDir() modelDir := filepath.Join(dir, "models") _ = os.MkdirAll(filepath.Join(modelDir, "wide", "active"), 0755) - os.WriteFile(filepath.Join(modelDir, "test-model.gguf"), []byte("dummy-model-data"), 0644) + _ = os.WriteFile(filepath.Join(modelDir, "test-model.gguf"), []byte("dummy-model-data"), 0644) s := New(modelDir, "mock") mux := http.NewServeMux() @@ -103,14 +103,14 @@ func TestCapabilities(t *testing.T) { if resp.StatusCode != 200 { t.Fatalf("expected 200, got %d: %s", resp.StatusCode, bodyString(t, resp)) } - resp.Body.Close() + _ = resp.Body.Close() } func TestTags(t *testing.T) { ts, dir := startTestServer(t) defer ts.Close() - os.WriteFile(filepath.Join(dir, "raw-model.gguf"), []byte("data"), 0644) + _ = os.WriteFile(filepath.Join(dir, "raw-model.gguf"), []byte("data"), 0644) resp := request(t, ts.URL+"/api/tags", "GET", nil) if resp.StatusCode != 200 { @@ -153,7 +153,7 @@ func TestGenerateWithoutPrompt(t *testing.T) { if resp.StatusCode == 200 { t.Fatal("expected error for missing prompt") } - resp.Body.Close() + _ = resp.Body.Close() } func TestChat(t *testing.T) { @@ -185,7 +185,7 @@ func TestChatWithoutMessages(t *testing.T) { if resp.StatusCode == 200 { t.Fatal("expected error for no messages") } - resp.Body.Close() + _ = resp.Body.Close() } func TestPs(t *testing.T) { @@ -196,7 +196,7 @@ func TestPs(t *testing.T) { if resp.StatusCode != 200 { t.Fatalf("expected 200, got %d: %s", resp.StatusCode, bodyString(t, resp)) } - resp.Body.Close() + _ = resp.Body.Close() } func TestDelete(t *testing.T) { @@ -207,7 +207,7 @@ func TestDelete(t *testing.T) { if resp.StatusCode != 200 { t.Fatalf("expected 200, got %d: %s", resp.StatusCode, bodyString(t, resp)) } - resp.Body.Close() + _ = resp.Body.Close() } func TestMethodNotAllowed(t *testing.T) { @@ -218,7 +218,7 @@ func TestMethodNotAllowed(t *testing.T) { if resp.StatusCode != 405 { t.Fatalf("expected 405, got %d: %s", resp.StatusCode, bodyString(t, resp)) } - resp.Body.Close() + _ = resp.Body.Close() } func TestGenerateStream(t *testing.T) { @@ -243,7 +243,7 @@ func TestGenerateStream(t *testing.T) { if err != nil { t.Fatalf("do request: %v", err) } - defer resp.Body.Close() + defer func() { _ = resp.Body.Close() }() if resp.StatusCode != 200 { t.Fatalf("expected 200, got %d: %s", resp.StatusCode, bodyString(t, resp)) @@ -276,7 +276,7 @@ func TestPullLocalFile(t *testing.T) { defer ts.Close() modelPath := filepath.Join(dir, "existing-model.gguf") - os.WriteFile(modelPath, []byte("data"), 0644) + _ = os.WriteFile(modelPath, []byte("data"), 0644) resp := request(t, ts.URL+"/api/pull", "POST", map[string]interface{}{ "name": "existing-model", @@ -285,5 +285,5 @@ func TestPullLocalFile(t *testing.T) { if resp.StatusCode != 200 { t.Fatalf("expected 200, got %d: %s", resp.StatusCode, bodyString(t, resp)) } - resp.Body.Close() + _ = resp.Body.Close() } From bf83a8e1c007a4cc47f3a4e1ef955b4624352735 Mon Sep 17 00:00:00 2001 From: Jean Machuca Date: Fri, 3 Jul 2026 21:17:54 +0000 Subject: [PATCH 7/7] fix: set CGO_ENABLED=0 for test and vet steps too --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a8e8ebf..b05268f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,11 @@ jobs: args: --timeout=3m - name: Test + env: + CGO_ENABLED: 0 run: go test ./... -v -count=1 - name: Vet + env: + CGO_ENABLED: 0 run: go vet ./...