Golang go/printer.Mode type examples

package go/printer

A Mode value is a set of flags (or 0). They control printing.

Golang go/printer.Mode type usage examples

Example 1:

 printConfig := &printer.Config{
 Mode: printerMode,  //<-- here
 Tabwidth: opt.TabWidth
 }

Example 2:

 func newPrinter(tabIndent bool, tabWidth int) *printer.Config {
  mode := printer.UseSpaces
  if tabIndent {
 mode |= printer.TabIndent
  }
  return &printer.Config{
 Mode: mode,
 Tabwidth: tabWidth,
  }
 }

Reference :

http://golang.org/pkg/go/printer/#Mode

Advertisement