Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lemonnekogh/gofmt.js


https://github.com/lemonnekogh/gofmt.js

Last synced: 11 days ago
JSON representation

Awesome Lists containing this project

README

        

# gofmt.js
A gofmt tool compiled by GopherJS.

## Get started
Install by npm:
```shell
npm install @lemonneko/gofmt.js
```
If you use commonjs:
```javascript
const gofmt = require('@lemonneko/gofmt.js')

console.log(gofmt.format(`type Person struct {
Name string \`json:"name"\`
Age int \`json:"age"\`
}`))
```
If you use esm:
```javascript
import gofmt from '@lemonneko/gofmt.js'

console.log(gofmt.format(`type Person struct {
Name string \`json:"name"\`
Age int \`json:"age"\`
}`))
```
The result should be:
```javascript
[
'type Person struct {\n' +
'\tName string `json:"name"`\n' +
'\tAge int `json:"age"`\n' +
'}',
''
]
```