@wasm-fmt/gofmt
v0.4.9
Published
A wasm based golang formatter
Downloads
1,775
Readme
Install
npm install @wasm-fmt/gofmt
npx jsr add @fmt/gofmt
Usage
import init, { format } from "@wasm-fmt/gofmt";
await init();
const source = `
package main
import "fmt"
func main(){fmt.Println("Hello, 世界")
}
`;
const formatted = format(source);
console.log(formatted);
Vite users tip:
import init, { format } from "@wasm-fmt/gofmt/vite";
Build from source
# 1. clone this repo
git clone https://github.com/wasm-fmt/gofmt.git
# 2. install TinyGo https://tinygo.org/getting-started/install/
# 3. build
pnpm build
# 4. test
pnpm run /^test:/