Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: resolve all golangci-lint issues (errcheck + staticcheck)

bot1fc52c867c11
diff --git a/cdp.go b/cdp.go
index c93c012c..9dd44fa8 100644
--- a/cdp.go
+++ b/cdp.go
@@ -193,7 +193,7 @@ func setResourceBlocking(ctx context.Context, patterns []string) error {
return chromedp.Run(ctx, chromedp.ActionFunc(func(ctx context.Context) error {
// Enable Network domain (idempotent).
if err := chromedp.FromContext(ctx).Target.Execute(ctx, "Network.enable", nil, nil); err != nil {
- return fmt.Errorf("Network.enable: %w", err)
+ return fmt.Errorf("network enable: %w", err)
}
if patterns == nil {
diff --git a/config_test.go b/config_test.go
index 75318c23..469e47f0 100644
--- a/config_test.go
+++ b/config_test.go
@@ -68,12 +68,11 @@ func TestLoadConfig_FromFile(t *testing.T) {
// Create a temp config file
dir := t.TempDir()
configPath := dir + "/config.json"
- os.WriteFile(configPath, []byte(`{"port":"7777"}`), 0644)
+ _ = os.WriteFile(configPath, []byte(`{"port":"7777"}`), 0644)
// Ensure env vars don't interfere
- os.Unsetenv("BRIDGE_PORT")
- os.Setenv("BRIDGE_CONFIG", configPath)
- defer os.Unsetenv("BRIDGE_CONFIG")
+ t.Setenv("BRIDGE_PORT", "")
+ t.Setenv("BRIDGE_CONFIG", configPath)
loadConfig()
if port != "7777" {
@@ -87,13 +86,11 @@ func TestLoadConfig_EnvOverridesFile(t *testing.T) {
dir := t.TempDir()
configPath := dir + "/config.json"
- os.WriteFile(configPath, []byte(`{"port":"7777"}`), 0644)
+ _ = os.WriteFile(configPath, []byte(`{"port":"7777"}`), 0644)
// Set BRIDGE_PORT env — loadConfig should NOT override port from file
- os.Setenv("BRIDGE_CONFIG", configPath)
- os.Setenv("BRIDGE_PORT", "8888")
- defer os.Unsetenv("BRIDGE_CONFIG")
- defer os.Unsetenv("BRIDGE_PORT")
+ t.Setenv("BRIDGE_CONFIG", configPath)
+ t.Setenv("BRIDGE_PORT", "8888")
// Simulate what happens: port was set at init from env, so set it manually
port = "8888"
@@ -107,7 +104,7 @@ func TestLoadConfig_EnvOverridesFile(t *testing.T) {
func TestLoadConfig_InvalidJSON(t *testing.T) {
dir := t.TempDir()
configPath := dir + "/config.json"
- os.WriteFile(configPath, []byte("{broken json!!!"), 0644)
+ _ = os.WriteFile(configPath, []byte("{broken json!!!"), 0644)
// Save and restore global state
origPort := port
diff --git a/state_test.go b/state_test.go
index a5ab11cc..14f8f38a 100644
--- a/state_test.go
+++ b/state_test.go
@@ -22,11 +22,11 @@ func TestMarkCleanExit_PatchesCrashed(t *testing.T) {
defer func() { profileDir = origProfileDir }()
prefsDir := filepath.Join(profileDir, "Default")
- os.MkdirAll(prefsDir, 0755)
+ _ = os.MkdirAll(prefsDir, 0755)
prefsPath := filepath.Join(prefsDir, "Preferences")
content := `{"profile":{"exit_type":"Crashed","exited_cleanly":false}}`
- os.WriteFile(prefsPath, []byte(content), 0644)
+ _ = os.WriteFile(prefsPath, []byte(content), 0644)
markCleanExit()
@@ -46,11 +46,11 @@ func TestMarkCleanExit_NoPatch(t *testing.T) {
defer func() { profileDir = origProfileDir }()
prefsDir := filepath.Join(profileDir, "Default")
- os.MkdirAll(prefsDir, 0755)
+ _ = os.MkdirAll(prefsDir, 0755)
prefsPath := filepath.Join(prefsDir, "Preferences")
content := `{"profile":{"exit_type":"Normal","exited_cleanly":true}}`
- os.WriteFile(prefsPath, []byte(content), 0644)
+ _ = os.WriteFile(prefsPath, []byte(content), 0644)
markCleanExit()
@@ -110,7 +110,7 @@ func TestRestoreState_EmptyTabs(t *testing.T) {
state := SessionState{Tabs: []TabState{}, SavedAt: "2026-02-17T07:00:00Z"}
data, _ := json.Marshal(state)
- os.WriteFile(filepath.Join(stateDir, "sessions.json"), data, 0644)
+ _ = os.WriteFile(filepath.Join(stateDir, "sessions.json"), data, 0644)
b := newTestBridge()
// Should return early — no tabs to restore
@@ -122,7 +122,7 @@ func TestRestoreState_InvalidJSON(t *testing.T) {
stateDir = t.TempDir()
defer func() { stateDir = origStateDir }()
- os.WriteFile(filepath.Join(stateDir, "sessions.json"), []byte("{broken"), 0644)
+ _ = os.WriteFile(filepath.Join(stateDir, "sessions.json"), []byte("{broken"), 0644)
b := newTestBridge()
// Should not panic on invalid JSON