@wasm-fmt/gofmt
v0.5.0
Published
A wasm based golang formatter
Readme
Install
npm install @wasm-fmt/gofmtnpx jsr add @fmt/gofmtUsage
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. install Go https://go.dev/doc/install
# 2. install TinyGo https://tinygo.org/getting-started/install/
# 3. clone this repo
git clone https://github.com/wasm-fmt/gofmt.git
# 4. install dependencies inside the repo
npm install
# 5. build
npm run build
# 6. test
npm run /^test:/