Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Latest commit

 

History

History
14 lines (11 loc) · 639 Bytes

README.md

File metadata and controls

14 lines (11 loc) · 639 Bytes

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.