Crush Go source files into a single line.
- You want to obfuscate your shitty code.
- You're trying to cheat at code golf.
- You're tired of those Go nerds telling you how to live your life.
package main
import (
"fmt"
"github.com/tomjcleveland/crush"
)
const helloWorld = `package main
import "fmt"
func main() {
fmt.Println("Hello, world!")
}`
func main() {
crushed, _ := crush.String(helloWorld)
fmt.Println(crushed)
// package main;import "fmt";func main() {fmt.Println("Hello, world!");};
}Yeah it's pretty complicated better check the Godocs.
If you ever decided to compile a formal EBNF description using the Go Spec, you'd actually discover that pretty much nothing we would call Go conforms to this grammar, because most of us use newlines (\n) instead of semicolons (;).
The Go people sell this as a feature, which ok I guess it is, but then can't you update the frigging EBNF?
I'm working on a tool that validates code based on EBNF, but it doesn't work for Go unless I crush it first, so that's actually why I wrote this.