summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPolo123456789 <[email protected]>2025-06-27 12:11:09 -0600
committerJay V <[email protected]>2025-06-27 19:10:42 -0400
commitd076def561d10167d984a4ef071e847d10bd8981 (patch)
tree2070ae73daf718ac6a6d5d400a92171386f5644f
parente0807d73177aa27a2be3d4910bab48a19c1480f2 (diff)
downloadopencode-d076def561d10167d984a4ef071e847d10bd8981.tar.gz
opencode-d076def561d10167d984a4ef071e847d10bd8981.zip
feat: Add golang file formatting (#474)
-rw-r--r--packages/opencode/src/format/index.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/packages/opencode/src/format/index.ts b/packages/opencode/src/format/index.ts
index 5ce27bc4e..2a189380b 100644
--- a/packages/opencode/src/format/index.ts
+++ b/packages/opencode/src/format/index.ts
@@ -142,5 +142,24 @@ export namespace Format {
}
},
},
+ {
+ name: "gofmt",
+ command: ["gofmt", "-w", "$FILE"],
+ extensions: [".go"],
+ async enabled() {
+ try {
+ const proc = Bun.spawn({
+ cmd: ["gofmt", "-h"],
+ cwd: App.info().path.cwd,
+ stdout: "ignore",
+ stderr: "ignore",
+ })
+ const exit = await proc.exited
+ return exit === 0
+ } catch {
+ return false
+ }
+ },
+ },
]
}