Skip to main content

@fmt/gofmt@0.4.9

A WASM Based Golang Formatter

Works with
This package works with Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Browsers
JSR Score
47%
Published
2 months ago (0.4.9)

Test

Install

npm

npm install @wasm-fmt/gofmt

jsr.io

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:/
Built and signed on
GitHub Actions
View transparency log

Add Package

deno add @fmt/gofmt

Import symbol

import * as mod from "@fmt/gofmt";

Add Package

npx jsr add @fmt/gofmt

Import symbol

import * as mod from "@fmt/gofmt";

Add Package

yarn dlx jsr add @fmt/gofmt

Import symbol

import * as mod from "@fmt/gofmt";

Add Package

pnpm dlx jsr add @fmt/gofmt

Import symbol

import * as mod from "@fmt/gofmt";

Add Package

bunx jsr add @fmt/gofmt

Import symbol

import * as mod from "@fmt/gofmt";