Skip to content

Commit 9edd4fd

Browse files
fix: resolve all lint errors from golangci-lint v2
- errcheck: explicitly ignore Close() errors with _ = c.Close() - revive: add doc comments on all exported types and functions - staticcheck: remove trailing \n from error format strings
1 parent bc4b1b2 commit 9edd4fd

5 files changed

Lines changed: 15 additions & 6 deletions

File tree

cmd/bridge/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func main() {
3232
if debugPath := os.Getenv("BRIDGE_DEBUG_LOG"); debugPath != "" {
3333
if f, err := os.OpenFile(debugPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644); err == nil {
3434
logger = log.New(io.MultiWriter(os.Stderr, f), "[codex-bridge] ", log.LstdFlags)
35-
defer f.Close()
35+
defer func() { _ = f.Close() }()
3636
}
3737
}
3838

@@ -71,7 +71,7 @@ func runMCP(pipeName string, logger *log.Logger) {
7171
fmt.Fprintf(os.Stderr, "Failed to connect: %v\n", err)
7272
os.Exit(1)
7373
}
74-
defer c.Close()
74+
defer func() { _ = c.Close() }()
7575

7676
logger.Println("Connected to Codex browser pipe, starting MCP server...")
7777

@@ -91,7 +91,7 @@ func runCLI(pipeName string, logger *log.Logger) {
9191
fmt.Fprintf(os.Stderr, "Failed to connect: %v\n", err)
9292
os.Exit(1)
9393
}
94-
defer c.Close()
94+
defer func() { _ = c.Close() }()
9595

9696
fmt.Println("Connected to Codex browser pipe")
9797
fmt.Println("Commands: tabs, create, close <id>, user-tabs, claim <id>, nav <id> <url>,")

internal/client/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func Connect(pipeName string, logger *log.Logger) (*Client, error) {
6666
// Health check: send a quick getInfo to verify the pipe is usable
6767
result, err := c.SendRequest("getInfo", nil)
6868
if err != nil {
69-
c.Close()
69+
_ = c.Close()
7070
lastErr = err
7171
if logger != nil {
7272
logger.Printf("pipe %s health check failed: %v, trying next...", p.UUID, err)
@@ -78,15 +78,15 @@ func Connect(pipeName string, logger *log.Logger) (*Client, error) {
7878
}
7979
return c, nil
8080
}
81-
return nil, fmt.Errorf("all %d pipes failed. Last error: %w\n"+
81+
return nil, fmt.Errorf("all %d pipes failed. Last error: %w"+
8282
"Try: restart Codex Desktop, then re-open the Codex Chrome Extension.",
8383
len(pipes), lastErr)
8484
}
8585

8686
path := discovery.PipePath(pipeName)
8787
conn, err := dialNamedPipe(path)
8888
if err != nil {
89-
return nil, fmt.Errorf("dial pipe %s: %w\n"+
89+
return nil, fmt.Errorf("dial pipe %s: %w"+
9090
"This usually means the pipe is stale (Codex Desktop restarted) or the extension lost its host.\n"+
9191
"Try: restart Codex Desktop, then re-open the Codex Chrome Extension.", path, err)
9292
}

internal/discovery/discovery.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
const codexPipePrefix = "codex-browser-use"
1010

11+
// PipeInfo holds the name and UUID of a discovered Codex named pipe.
1112
type PipeInfo struct {
1213
Name string
1314
UUID string
@@ -44,6 +45,7 @@ func extractUUID(name string) string {
4445
return rest
4546
}
4647

48+
// PipePath returns the full \\.\pipe\ path for a named pipe.
4749
func PipePath(name string) string {
4850
return `\\.\pipe\` + name
4951
}

internal/mcp/server.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/DeliciousBuding/codex-browser-bridge/internal/client"
1212
)
1313

14+
// MCPServer is an MCP stdio server that exposes browser automation tools.
1415
type MCPServer struct {
1516
client *client.Client
1617
tools []Tool
@@ -20,6 +21,7 @@ type MCPServer struct {
2021
version string
2122
}
2223

24+
// Tool defines an MCP tool exposed by the server.
2325
type Tool struct {
2426
Name string `json:"name"`
2527
Description string `json:"description"`
@@ -43,10 +45,12 @@ func imageContent(b64, mime string) Content {
4345
return Content{Type: "image", Data: b64, MimeType: mime}
4446
}
4547

48+
// NewMCPServer creates an MCP server using os.Stdin and os.Stdout for transport.
4649
func NewMCPServer(c *client.Client) *MCPServer {
4750
return NewMCPServerWithIO(c, os.Stdin, os.Stdout)
4851
}
4952

53+
// NewMCPServerWithIO creates an MCP server with custom I/O streams.
5054
func NewMCPServerWithIO(c *client.Client, in io.Reader, out io.Writer) *MCPServer {
5155
s := &MCPServer{
5256
client: c,

internal/protocol/protocol.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,22 @@ import (
99

1010
// JSON-RPC 2.0 message types (Codex uses JSON-RPC without the "jsonrpc":"2.0" field on responses)
1111

12+
// Request is a JSON-RPC 2.0 request message.
1213
type Request struct {
1314
JSONRPC string `json:"jsonrpc"`
1415
ID int `json:"id"`
1516
Method string `json:"method"`
1617
Params interface{} `json:"params,omitempty"`
1718
}
1819

20+
// Response is a JSON-RPC 2.0 response message.
1921
type Response struct {
2022
ID int `json:"id"`
2123
Result json.RawMessage `json:"result,omitempty"`
2224
Error *ErrorObject `json:"error,omitempty"`
2325
}
2426

27+
// ErrorObject carries a JSON-RPC error.
2528
type ErrorObject struct {
2629
Code int `json:"code"`
2730
Message string `json:"message"`

0 commit comments

Comments
 (0)