Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/go-toolsmith/minformat
gominfmt makes the Go code more compact to aid further compression; revert with gofmt
https://github.com/go-toolsmith/minformat
compression fmt go golang minifier uglify
Last synced: 8 days ago
JSON representation
gominfmt makes the Go code more compact to aid further compression; revert with gofmt
- Host: GitHub
- URL: https://github.com/go-toolsmith/minformat
- Owner: go-toolsmith
- License: mit
- Created: 2020-10-04T06:32:18.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-01-17T20:39:27.000Z (10 months ago)
- Last Synced: 2024-08-02T14:06:15.394Z (3 months ago)
- Topics: compression, fmt, go, golang, minifier, uglify
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 25
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Go Report Card](https://goreportcard.com/badge/github.com/quasilyte/minformat)](https://goreportcard.com/report/github.com/quasilyte/minformat)
[![GoDoc](https://godoc.org/github.com/quasilyte/minformat/go/minformat?status.svg)](https://godoc.org/github.com/quasilyte/minformat/go/minformat)# `go/minformat`
This package formats the Go source code in a way so it becomes more compact.
It can be considered to be a minifier, although it doesn't make irreversible transformations by default (well, it does remove all comments).The result can become readable again after running `go/format`, making this pipeline possible:
1. Minify the code before transferring it over a network
2. Send the (potentially further compressed) minified source code
3. On the receiving side, run `gofmt` to get the canonical formattingFor (3) I would recommend using [gofumpt](https://github.com/mvdan/gofumpt).
## Example
Suppose that we have this `hello.go` file:
```go
package mainimport (
"fmt"
)func main() {
fmt.Println("Hello, playground")
}
```It will be formatted into this:
```go
package main;import("fmt");func main(){fmt.Println("Hello, playground")}
```Depending on the file, it usually cuts 10-50% of the file size.