Skip to content

Commit 4ec7fa6

Browse files
Alejandro Maggiclaude
authored andcommitted
Apply gofumpt formatting fixes
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b32f2e3 commit 4ec7fa6

10 files changed

Lines changed: 59 additions & 57 deletions

File tree

pkg/cli/cli_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ func TestIsSocketInUse_ActiveSocket(t *testing.T) {
798798
defer func() { _ = os.Remove(socketPath) }()
799799

800800
// Write PID file for current process (simulates active owner)
801-
if err := os.WriteFile(pidPath, []byte(strconv.Itoa(os.Getpid())), 0644); err != nil {
801+
if err := os.WriteFile(pidPath, []byte(strconv.Itoa(os.Getpid())), 0o644); err != nil {
802802
t.Fatalf("failed to write PID file: %v", err)
803803
}
804804
defer func() { _ = os.Remove(pidPath) }()
@@ -844,7 +844,7 @@ func TestIsSocketInUse_DeadOwner(t *testing.T) {
844844
defer func() { _ = os.Remove(socketPath) }()
845845

846846
// Write PID file with a PID that doesn't exist (simulate dead owner)
847-
if err := os.WriteFile(pidPath, []byte("99999999"), 0644); err != nil {
847+
if err := os.WriteFile(pidPath, []byte("99999999"), 0o644); err != nil {
848848
t.Fatalf("failed to write PID file: %v", err)
849849
}
850850
defer func() { _ = os.Remove(pidPath) }()
@@ -2116,7 +2116,7 @@ func TestIsSocketInUse_SocketFileExistsButNoPidFile(t *testing.T) {
21162116
socketPath := dir + "/test.sock"
21172117

21182118
// Create socket file (just a regular file to simulate existence)
2119-
if err := os.WriteFile(socketPath, []byte{}, 0644); err != nil {
2119+
if err := os.WriteFile(socketPath, []byte{}, 0o644); err != nil {
21202120
t.Fatalf("failed to create socket file: %v", err)
21212121
}
21222122

@@ -2132,12 +2132,12 @@ func TestIsSocketInUse_SocketAndPidWithLiveProcess(t *testing.T) {
21322132
pidPath := strings.TrimSuffix(socketPath, ".sock") + ".pid"
21332133

21342134
// Create socket file
2135-
if err := os.WriteFile(socketPath, []byte{}, 0644); err != nil {
2135+
if err := os.WriteFile(socketPath, []byte{}, 0o644); err != nil {
21362136
t.Fatalf("failed to create socket file: %v", err)
21372137
}
21382138

21392139
// Write current process PID
2140-
if err := os.WriteFile(pidPath, []byte(strconv.Itoa(os.Getpid())), 0644); err != nil {
2140+
if err := os.WriteFile(pidPath, []byte(strconv.Itoa(os.Getpid())), 0o644); err != nil {
21412141
t.Fatalf("failed to write PID file: %v", err)
21422142
}
21432143

@@ -2153,12 +2153,12 @@ func TestIsSocketInUse_SocketAndPidWithDeadProcess(t *testing.T) {
21532153
pidPath := strings.TrimSuffix(socketPath, ".sock") + ".pid"
21542154

21552155
// Create socket file
2156-
if err := os.WriteFile(socketPath, []byte{}, 0644); err != nil {
2156+
if err := os.WriteFile(socketPath, []byte{}, 0o644); err != nil {
21572157
t.Fatalf("failed to create socket file: %v", err)
21582158
}
21592159

21602160
// Write dead PID
2161-
if err := os.WriteFile(pidPath, []byte("99999999"), 0644); err != nil {
2161+
if err := os.WriteFile(pidPath, []byte("99999999"), 0o644); err != nil {
21622162
t.Fatalf("failed to write PID file: %v", err)
21632163
}
21642164

pkg/cli/test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ import (
3333

3434
// activeCleanup holds the current driver cleanup function so the signal handler
3535
// can clean up resources (sockets, adb forwards, sessions) before os.Exit.
36-
var activeCleanup func()
37-
var cleanupMu sync.Mutex
36+
var (
37+
activeCleanup func()
38+
cleanupMu sync.Mutex
39+
)
3840

3941
var testCommand = &cli.Command{
4042
Name: "test",

pkg/core/driver_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ func TestHasNonASCII(t *testing.T) {
235235
{"Hello World 123!", false},
236236
{"", false},
237237
{"abc\t\n", false},
238-
{"\x7f", false}, // DEL is ASCII (127)
239-
{"\x80", true}, // first non-ASCII byte
238+
{"\x7f", false}, // DEL is ASCII (127)
239+
{"\x80", true}, // first non-ASCII byte
240240
{"cafe\u0301", true}, // e with combining accent
241241
{"hello world", false},
242242
}

pkg/device/devicelab_driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func (d *AndroidDevice) setupDeviceLabSocketForward(cfg DeviceLabDriverConfig) e
200200
d.driverSocketPath = socketPath
201201

202202
// Write PID file
203-
if err := os.WriteFile(pidPathFor(socketPath), []byte(strconv.Itoa(os.Getpid())), 0644); err != nil {
203+
if err := os.WriteFile(pidPathFor(socketPath), []byte(strconv.Itoa(os.Getpid())), 0o644); err != nil {
204204
logger.Warn("failed to write DeviceLab Android Driver PID file: %v", err)
205205
}
206206

pkg/device/uiautomator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (d *AndroidDevice) setupSocketForward(cfg UIAutomator2Config) error {
124124
d.socketPath = socketPath
125125

126126
// Write PID file so other instances can detect us as the owner
127-
if err := os.WriteFile(pidPathFor(socketPath), []byte(strconv.Itoa(os.Getpid())), 0644); err != nil {
127+
if err := os.WriteFile(pidPathFor(socketPath), []byte(strconv.Itoa(os.Getpid())), 0o644); err != nil {
128128
logger.Warn("failed to write PID file: %v", err)
129129
}
130130

pkg/device/uiautomator_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func TestIsOwnerAlive_CurrentProcess(t *testing.T) {
8080

8181
// Write current process PID
8282
pid := os.Getpid()
83-
if err := os.WriteFile(pidPath, []byte(strconv.Itoa(pid)), 0644); err != nil {
83+
if err := os.WriteFile(pidPath, []byte(strconv.Itoa(pid)), 0o644); err != nil {
8484
t.Fatalf("failed to write PID file: %v", err)
8585
}
8686

@@ -97,7 +97,7 @@ func TestIsOwnerAlive_DeadProcess(t *testing.T) {
9797

9898
// Write a PID that almost certainly does not exist
9999
// Use a very high PID number that is unlikely to be in use
100-
if err := os.WriteFile(pidPath, []byte("99999999"), 0644); err != nil {
100+
if err := os.WriteFile(pidPath, []byte("99999999"), 0o644); err != nil {
101101
t.Fatalf("failed to write PID file: %v", err)
102102
}
103103

@@ -113,7 +113,7 @@ func TestIsOwnerAlive_InvalidPidContent(t *testing.T) {
113113
pidPath := pidPathFor(socketPath)
114114

115115
// Write non-numeric content
116-
if err := os.WriteFile(pidPath, []byte("not-a-pid"), 0644); err != nil {
116+
if err := os.WriteFile(pidPath, []byte("not-a-pid"), 0o644); err != nil {
117117
t.Fatalf("failed to write PID file: %v", err)
118118
}
119119

@@ -129,7 +129,7 @@ func TestIsOwnerAlive_EmptyPidFile(t *testing.T) {
129129
pidPath := pidPathFor(socketPath)
130130

131131
// Write empty file
132-
if err := os.WriteFile(pidPath, []byte(""), 0644); err != nil {
132+
if err := os.WriteFile(pidPath, []byte(""), 0o644); err != nil {
133133
t.Fatalf("failed to write PID file: %v", err)
134134
}
135135

@@ -146,7 +146,7 @@ func TestIsOwnerAlive_PidWithWhitespace(t *testing.T) {
146146

147147
// Write PID with leading/trailing whitespace and newline
148148
pid := os.Getpid()
149-
if err := os.WriteFile(pidPath, []byte(" "+strconv.Itoa(pid)+"\n"), 0644); err != nil {
149+
if err := os.WriteFile(pidPath, []byte(" "+strconv.Itoa(pid)+"\n"), 0o644); err != nil {
150150
t.Fatalf("failed to write PID file: %v", err)
151151
}
152152

@@ -162,7 +162,7 @@ func TestIsOwnerAlive_NegativePid(t *testing.T) {
162162
pidPath := pidPathFor(socketPath)
163163

164164
// Write negative PID
165-
if err := os.WriteFile(pidPath, []byte("-1"), 0644); err != nil {
165+
if err := os.WriteFile(pidPath, []byte("-1"), 0o644); err != nil {
166166
t.Fatalf("failed to write PID file: %v", err)
167167
}
168168

@@ -180,7 +180,7 @@ func TestIsOwnerAlive_ZeroPid(t *testing.T) {
180180
pidPath := pidPathFor(socketPath)
181181

182182
// Write PID 0
183-
if err := os.WriteFile(pidPath, []byte("0"), 0644); err != nil {
183+
if err := os.WriteFile(pidPath, []byte("0"), 0o644); err != nil {
184184
t.Fatalf("failed to write PID file: %v", err)
185185
}
186186

@@ -204,7 +204,7 @@ func TestFindAPK_NoMatch(t *testing.T) {
204204
func TestFindAPK_MatchesFile(t *testing.T) {
205205
dir := t.TempDir()
206206
apkPath := filepath.Join(dir, "test-v1.0.apk")
207-
if err := os.WriteFile(apkPath, []byte("fake apk"), 0644); err != nil {
207+
if err := os.WriteFile(apkPath, []byte("fake apk"), 0o644); err != nil {
208208
t.Fatalf("failed to create test APK: %v", err)
209209
}
210210

pkg/driver/uiautomator2/commands_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func TestLaunchAppShellResolveActivity(t *testing.T) {
167167
shell := &shellMock{
168168
responses: map[string]string{
169169
"getprop ro.build.version.sdk": "30",
170-
"resolve-activity": "com.example.app/.MainActivity",
170+
"resolve-activity": "com.example.app/.MainActivity",
171171
},
172172
fallback: "Success",
173173
}
@@ -220,7 +220,7 @@ func TestLaunchAppShellAmStartForOlderAPI(t *testing.T) {
220220
shell := &shellMock{
221221
responses: map[string]string{
222222
"getprop ro.build.version.sdk": "25",
223-
"resolve-activity": "com.example.app/.MainActivity",
223+
"resolve-activity": "com.example.app/.MainActivity",
224224
},
225225
fallback: "Success",
226226
}
@@ -284,7 +284,7 @@ func TestLaunchAppMonkeyFallbackResolveFailed(t *testing.T) {
284284
shell := &shellMock{
285285
responses: map[string]string{
286286
"getprop ro.build.version.sdk": "30",
287-
"resolve-activity": "No activity found",
287+
"resolve-activity": "No activity found",
288288
},
289289
errors: map[string]error{
290290
"dumpsys package": fmt.Errorf("dumpsys failed"),
@@ -316,7 +316,7 @@ func TestLaunchAppMonkeyAborted(t *testing.T) {
316316
shell := &shellMock{
317317
responses: map[string]string{
318318
"getprop ro.build.version.sdk": "30",
319-
"resolve-activity": "No activity found",
319+
"resolve-activity": "No activity found",
320320
"monkey": "monkey aborted",
321321
},
322322
errors: map[string]error{
@@ -389,7 +389,7 @@ func TestLaunchAppDumpsysFallbackWithArgs(t *testing.T) {
389389
shell := &shellMock{
390390
responses: map[string]string{
391391
"getprop ro.build.version.sdk": "30",
392-
"resolve-activity": "No activity found",
392+
"resolve-activity": "No activity found",
393393
"dumpsys package": "com.example.app/.MainActivity filter abc123\n" +
394394
" Action: \"android.intent.action.MAIN\"\n" +
395395
" Category: \"android.intent.category.LAUNCHER\"\n",
@@ -425,7 +425,7 @@ func TestLaunchAppDotPrefixRetry(t *testing.T) {
425425
shell := &shellMock{
426426
responses: map[string]string{
427427
"getprop ro.build.version.sdk": "30",
428-
"resolve-activity": "com.example.app/MainActivity",
428+
"resolve-activity": "com.example.app/MainActivity",
429429
},
430430
fallback: "Success",
431431
}
@@ -3915,11 +3915,11 @@ func TestResolveLauncherActivity(t *testing.T) {
39153915

39163916
func TestLaunchWithMonkey(t *testing.T) {
39173917
tests := []struct {
3918-
name string
3919-
appID string
3920-
output string
3921-
err error
3922-
wantOK bool
3918+
name string
3919+
appID string
3920+
output string
3921+
err error
3922+
wantOK bool
39233923
}{
39243924
{
39253925
name: "successful launch",
@@ -3974,7 +3974,7 @@ func TestLaunchAppViaShellWithArgTypes(t *testing.T) {
39743974
shell := &shellMock{
39753975
responses: map[string]string{
39763976
"getprop ro.build.version.sdk": "30",
3977-
"resolve-activity": "com.example.app/.MainActivity",
3977+
"resolve-activity": "com.example.app/.MainActivity",
39783978
},
39793979
fallback: "Success",
39803980
}
@@ -3983,7 +3983,7 @@ func TestLaunchAppViaShellWithArgTypes(t *testing.T) {
39833983
// Test with multiple argument types
39843984
args := map[string]interface{}{
39853985
"stringKey": "stringValue",
3986-
"intKey": float64(42), // JSON unmarshals numbers as float64
3986+
"intKey": float64(42), // JSON unmarshals numbers as float64
39873987
"floatKey": float64(3.14),
39883988
"boolKey": true,
39893989
}
@@ -4026,8 +4026,8 @@ func TestLaunchAppViaShellAmStartError(t *testing.T) {
40264026
shell := &shellMock{
40274027
responses: map[string]string{
40284028
"getprop ro.build.version.sdk": "30",
4029-
"resolve-activity": "com.example.app/.MainActivity",
4030-
"am start-activity": "Error: Activity not started",
4029+
"resolve-activity": "com.example.app/.MainActivity",
4030+
"am start-activity": "Error: Activity not started",
40314031
"monkey": "Events injected: 1",
40324032
},
40334033
fallback: "",
@@ -4046,8 +4046,8 @@ func TestLaunchAppViaShellAmStartErrorWithArgs(t *testing.T) {
40464046
shell := &shellMock{
40474047
responses: map[string]string{
40484048
"getprop ro.build.version.sdk": "30",
4049-
"resolve-activity": "com.example.app/.MainActivity",
4050-
"am start-activity": "Error: Activity not started",
4049+
"resolve-activity": "com.example.app/.MainActivity",
4050+
"am start-activity": "Error: Activity not started",
40514051
},
40524052
fallback: "",
40534053
}

pkg/driver/wda/driver.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -562,12 +562,12 @@ func (d *Driver) getElementInfo(elemID string) (*core.ElementInfo, error) {
562562
}
563563

564564
var (
565-
text string
566-
elemName string
567-
x, y, w, h int
568-
displayed bool
565+
text string
566+
elemName string
567+
x, y, w, h int
568+
displayed bool
569569
textErr, rectErr, dispErr, nameErr error
570-
wg sync.WaitGroup
570+
wg sync.WaitGroup
571571
)
572572

573573
wg.Add(4)

pkg/maestro/protocol.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ type rawMessage struct {
4848
// ElementResult is the result returned by UI.findElement.
4949
// It bundles element ID with commonly needed attributes to avoid extra round-trips.
5050
type ElementResult struct {
51-
ElementID string `json:"elementId"`
52-
Text string `json:"text"`
53-
ContentDesc string `json:"contentDesc"`
54-
ClassName string `json:"className"`
55-
ResourceID string `json:"resourceId"`
51+
ElementID string `json:"elementId"`
52+
Text string `json:"text"`
53+
ContentDesc string `json:"contentDesc"`
54+
ClassName string `json:"className"`
55+
ResourceID string `json:"resourceId"`
5656
Bounds BoundsResult `json:"bounds"`
57-
Displayed bool `json:"displayed"`
58-
Enabled bool `json:"enabled"`
59-
Clickable bool `json:"clickable"`
60-
Selected bool `json:"selected"`
57+
Displayed bool `json:"displayed"`
58+
Enabled bool `json:"enabled"`
59+
Clickable bool `json:"clickable"`
60+
Selected bool `json:"selected"`
6161
}
6262

6363
// BoundsResult represents element bounds.
@@ -70,7 +70,7 @@ type BoundsResult struct {
7070

7171
// SessionResult is returned by Session.create.
7272
type SessionResult struct {
73-
SessionID string `json:"sessionId"`
73+
SessionID string `json:"sessionId"`
7474
DeviceInfo DeviceResult `json:"deviceInfo"`
7575
}
7676

@@ -87,7 +87,7 @@ type DeviceResult struct {
8787

8888
// KeyboardInfo is returned by Device.getKeyboardInfo and pushed via Input.keyboardStateChanged.
8989
type KeyboardInfo struct {
90-
Visible bool `json:"visible"`
90+
Visible bool `json:"visible"`
9191
Bounds *BoundsResult `json:"bounds,omitempty"`
9292
}
9393

pkg/simulator/ios.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@ type simctlRuntimesOutput struct {
237237
}
238238

239239
type simctlRuntime struct {
240-
Identifier string `json:"identifier"`
241-
Version string `json:"version"`
242-
IsAvailable bool `json:"isAvailable"`
240+
Identifier string `json:"identifier"`
241+
Version string `json:"version"`
242+
IsAvailable bool `json:"isAvailable"`
243243
SupportedDeviceTypes []simctlDeviceTypeEntry `json:"supportedDeviceTypes"`
244244
}
245245

0 commit comments

Comments
 (0)