tabwriter

package
v0.0.0-...-c8a214a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2018 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Overview

Package tabwriter provides a set of sane defaults for converting tab separated values into a pretty column formatted output.

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	MinWidth: 5,
	TabWidth: 0,
	Padding:  2,
	PadChar:  ' ',
	Flags:    0,
}

DefaultConfig is the tabwriter config that will be used if none is specified.

Functions

func Format

func Format(in string) string

Format returns the input with the content aligned by tabs. If a config is specified it will be used otherwise DefaultConfig will be used.

func FormatWithHeader

func FormatWithHeader(hdr, in string) string

FormatWithHeader returns the input with the content aligned by tabs and includes a header even if no data is provided. If a config is specified it will be used otherwise DefaultConfig will be used.

Types

type Config

type Config struct {
	// MinWidth is the minimal cell width including any padding
	MinWidth int

	// TabWidth is the width of a tab characters (equivalent number of spaces)
	TabWidth int

	// Padding is added to a cell before computing its width
	Padding int

	// PadChar is an ASCII char used for padding; see more detail in
	// https://golang.org/pkg/text/tabwriter/#NewWriter
	PadChar byte

	// Flags specify formatting controls; see more detail in
	// https://golang.org/pkg/text/tabwriter/#pkg-constants
	Flags uint
}

type TbnTabWriter

type TbnTabWriter interface {
	// Format returns the input with the content aligned by tabs.
	Format(string) string

	// FormatWithHeader returns the input with the content aligned by tabs and
	// includes a header even if no data is provided.
	FormatWithHeader(string, string) string
}

func New

func New(cfg Config) TbnTabWriter

New constructs a new TbnTabWriter with the provided output config.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL