Source (bytes)
out, err := format.Source([]byte("package p\nvar x=1"))
// out == "package p\n\nvar x = 1\n"
go/formatgofmt as a library. Format Go source bytes or an AST node back to canonical form.
out, err := format.Source([]byte("package p\nvar x=1"))
// out == "package p\n\nvar x = 1\n"
var buf bytes.Buffer
format.Node(&buf, fset, file)
fmt.Println(buf.String())