Skip to content

Commit 7eb11a7

Browse files
authored
Create README.md
1 parent 3f77181 commit 7eb11a7

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[![Go Report Card](https://goreportcard.com/badge/github.com/quasilyte/minformat)](https://goreportcard.com/report/github.com/quasilyte/minformat)
2+
[![GoDoc](https://godoc.org/github.com/quasilyte/minformat/go/minformat?status.svg)](https://godoc.org/github.com/quasilyte/minformat/go/minformat)
3+
4+
# `go/minformat`
5+
6+
This package formats the Go source code in a way so it becomes more compact.
7+
It can be considered to be a minifier, although it doesn't make irreversible transformations by default (well, it does remove all comments).
8+
9+
The result can become readable again after running `go/format`, making this pipeline possible:
10+
11+
1. Minify the code before transferring it over a network
12+
2. Send the (potentially further compressed) minified source code
13+
3. On the receiving side, run `gofmt` to get the canonical formatting
14+
15+
For (3) I would recommend using [gofumpt](https://github.com/mvdan/gofumpt).
16+
17+
## Example
18+
19+
Suppose that we have this `hello.go` file:
20+
21+
```go
22+
package main
23+
24+
import (
25+
"fmt"
26+
)
27+
28+
func main() {
29+
fmt.Println("Hello, playground")
30+
}
31+
```
32+
33+
It will be formatted into this:
34+
35+
```go
36+
package main;import("fmt");func main(){fmt.Println("Hello, playground")}
37+
```
38+
39+
Depending on the file, it usually cuts 10-50% of the file size.

0 commit comments

Comments
 (0)