0.0.2 • Published 1 year ago

gofmtr v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

gofmtr

gofmtr is a simple npm package that exports a single function for formatting Go code. It's a lightweight, pure-JavaScript implementation of the gofmt command, and it can be used in any JavaScript environment.

Installation

To install gofmtr, simply run the following command:

npm install gofmtr

Usage

To use gofmtr, import the gofmt function from the package and pass it a string containing Go code. The function will return a new string with the formatted code:

import { gofmt } from 'gofmtr';

const code = `
  package main

  import "fmt"

  func main() {
    fmt.Println("Hello, world!")
  }
`;

console.log(gofmt(code));

License

gofmtr is released under the MIT license. See LICENSE for more details.