Skip to content

Custom Renderer

If the custom formatting and layout don't meet your needs, you can simply specify your own rendering function.

Tip

Want to try? See the custom renderer example!

func main() {
    renderFn := func(in *version.Info, isSmartTerminal bool) (string, error) {
        return fmt.Sprintf(`
      Version             %q
      Git Commit          %.4s
   `, in.Version, in.GitCommit), nil
    }

    p := printer.New(printer.WithPrettyRenderer(renderFn))
    if err := p.Print(os.Stdout); err != nil {
        log.Fatal(err)
    }
}
Back to top