Quickstart: Generate a basic Go file
masterUse NewFile to create a new Go file and chain methods to build its structure. Jennifer uses a fluent API to construct identifiers, functions, and blocks.
package main
import (
"fmt"
. "github.com/dave/jennifer/jen"
)
func main() {
f := NewFile("main")
f.Func().Id("main").Params().Block(
Qual("fmt", "Println").Call(Lit("Hello, world")),
)
fmt.Printf("%#v", f)
}