gofmt.js

0.0.2 • Public • Published

This is the gofmt tool compiled via GopherJS into JavaScript. It's about a megabyte big, and works with Node and the browser (and probably require.js too). The interface is just one function:

var gofmt = require('gofmt.js');
console.log(gofmt("func main() {\nprintln() }"));
// prints:
// func main() {
//     println()
// }

If you include gofmt.js in the browser, the formatting function is exposed as window.gofmt. This function returns false if there was an error, and a string containing the formatted code otherwise.

As of this writing, this was compiled from Go 1.7.4's formatting code.

Readme

Keywords

none

Package Sidebar

Install

npm i gofmt.js

Weekly Downloads

250

Version

0.0.2

License

BSD-3-Clause

Last publish

Collaborators

  • coderpad