Skip to content

Commit df3b424

Browse files
feat: Add golang file formatting (anomalyco#474)
1 parent 3cfd9d8 commit df3b424

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

packages/opencode/src/format/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,24 @@ export namespace Format {
142142
}
143143
},
144144
},
145+
{
146+
name: "gofmt",
147+
command: ["gofmt", "-w", "$FILE"],
148+
extensions: [".go"],
149+
async enabled() {
150+
try {
151+
const proc = Bun.spawn({
152+
cmd: ["gofmt", "-h"],
153+
cwd: App.info().path.cwd,
154+
stdout: "ignore",
155+
stderr: "ignore",
156+
})
157+
const exit = await proc.exited
158+
return exit === 0
159+
} catch {
160+
return false
161+
}
162+
},
163+
},
145164
]
146165
}

0 commit comments

Comments
 (0)