tablewriter

package module
v0.0.0-...-7284dac Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cell

type Cell struct {
	Value        interface{}
	StringLength int
}

func NewCell

func NewCell(v reflect.Value) (Cell, error)

type Column

type Column struct {
	Name       string
	Length     int
	IntAsFloat bool
}

type Writer

type Writer struct {
	// contains filtered or unexported fields
}
Example
package main

import (
	"github.com/chiyouhen/tablewriter"
	"os"
)

func main() {
	type User struct {
		Name  string
		Age   int
		Speed float64
	}

	users := []User{
		{
			"John", 15, 14.3,
		},
		{
			"Mike", 14, 11.5,
		},
	}
	wr := tablewriter.NewWriter(os.Stdout, []string{"Name", "Age", "Speed"})
	for _, u := range users {
		wr.Write(u)
	}
	wr.Flush()
	// output
	// Name Age Speed
	// John  15 14.300000
	// Mike  14 11.500000
}
Output:

func NewWriter

func NewWriter(ww io.Writer, columns []string) *Writer

func (*Writer) Flush

func (wr *Writer) Flush() error

func (*Writer) Write

func (wr *Writer) Write(d interface{}) error

Jump to

Keyboard shortcuts

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