Go hello world through gofmt
- Language
- Go
- Source code
- package main import "fmt" func main(){ fmt.Println("hi") }
- clang-format style
- LLVM
- Indent width
- Style default
- Lua indentation
- Tabs
Result Formatted code: package main
import "fmt"
func main() {
fmt.Println("hi")
}
Lines out: 7
Lines rewritten: 2
- gofmt: tabs for indentation, spaces for alignment, imports and declarations in canonical layout
- Read 5 lines of Go; parsed into a syntax tree
- Printed 7 lines; 2 differ from the input
The body gains a tab indent, the brace moves onto the func line and blank lines separate package, import and func, exactly as go fmt writes it.