Documentation ¶
Index ¶
- Constants
- type Flag
- type Option
- type Writer
- func (w *Writer) AppendBool(b bool, width int, flag Flag)
- func (w *Writer) AppendBytes(bs []byte, width int, flag Flag)
- func (w *Writer) AppendDuration(d time.Duration, width int, flag Flag)
- func (w *Writer) AppendFloat(v float64, width, prec int, flag Flag)
- func (w *Writer) AppendInt(v int64, width int, flag Flag)
- func (w *Writer) AppendPercent(v float64, width, prec int, flag Flag)
- func (w *Writer) AppendSeparator(n int)
- func (w *Writer) AppendSize(v int64, width int, flag Flag)
- func (w *Writer) AppendString(str string, width int, flag Flag)
- func (w *Writer) AppendTime(t time.Time, format string, flag Flag)
- func (w *Writer) AppendUint(v uint64, width int, flag Flag)
- func (w *Writer) Bytes() []byte
- func (w *Writer) Read(bs []byte) (int, error)
- func (w *Writer) Reset()
- func (w *Writer) String() string
- func (w *Writer) WriteTo(ws io.Writer) (int64, error)
Examples ¶
Constants ¶
View Source
const DefaultFlags = AlignRight | Text | Second | TrueFalse | Decimal | Float | SizeIEC
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Writer)
func AsCSV ¶
Example ¶
w1 := NewWriter(256, AsCSV(false)) w1.AppendUint(1, 4, AlignRight) w1.AppendUint(1, 4, AlignRight|Hex|WithZero) w1.AppendString("playback", 10, AlignLeft) w1.AppendUint(44, 2, AlignLeft|Decimal) w1.AppendBool(false, 3, AlignCenter|OnOff) w2 := NewWriter(256, AsCSV(true)) w2.AppendUint(1, 4, AlignRight) w2.AppendUint(1, 4, AlignRight|Hex|WithZero) w2.AppendString("playback", 10, AlignLeft) w2.AppendUint(44, 2, AlignLeft|Decimal) w2.AppendBool(false, 3, AlignCenter|OnOff) fmt.Println(w1.String()) fmt.Println(w2.String())
Output: 1,0001,playback,44,off "1","0001","playback","44","off"
func WithPadding ¶
func WithSeparator ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Example ¶
w1 := NewWriter(256, WithPadding([]byte("_")), WithSeparator([]byte("|"))) w1.AppendUint(1, 4, AlignRight) w1.AppendUint(1, 4, AlignRight|Hex|WithZero) w1.AppendString("playback", 10, AlignLeft) w1.AppendUint(44, 2, AlignLeft|Decimal) w1.AppendBool(false, 3, AlignCenter|OnOff) w2 := NewWriter(256, WithPadding([]byte("_")), WithSeparator([]byte("|")), WithLabel("[label]")) w2.AppendUint(1, 4, AlignRight) w2.AppendUint(1, 4, AlignRight|Hex|WithZero) w2.AppendString("playback", 10, AlignLeft) w2.AppendUint(44, 2, AlignLeft|Decimal) w2.AppendBool(false, 3, AlignCenter|OnOff) fmt.Println(w1.String()) fmt.Println(w2.String())
Output: _ 1_|_0001_|_playback _|_44_|_off_ [label]_ 1_|_0001_|_playback _|_44_|_off_
func (*Writer) AppendDuration ¶
func (*Writer) AppendPercent ¶
func (*Writer) AppendSeparator ¶
Example ¶
w1 := NewWriter(256, WithPadding([]byte("_")), WithSeparator([]byte("|"))) w1.AppendUint(1, 4, AlignRight) w1.AppendUint(1, 4, AlignRight|Hex|WithZero) w1.AppendSeparator(1) w1.AppendString("playback", 10, AlignLeft) w1.AppendSeparator(3) w1.AppendUint(44, 2, AlignLeft|Decimal) w1.AppendBool(false, 3, AlignCenter|OnOff) fmt.Println(w1.String())
Output: _ 1_|_0001_||_playback _|||_44_|_off_
Click to show internal directories.
Click to hide internal directories.