unixtable

package module
v0.0.0-...-652fb1b Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 7 Imported by: 0

README

go-encoding-unixtable CI godoc goreportcard license

Golang module akin to encoding/json but for encoding structs to a unixtable format for readability:

Id   Name               Age
1    Obi-Wan Kenobi     35
2    General Grievous   50

Useful for displaying CLI output (think kubectl get pods).

install

go get github.com/frantjc/go-encoding-unixtable

use

See example.

Documentation

Index

Constants

View Source
const (
	DefaultPadding  = 3
	DefaultTabWidth = 2
	DefaultMinWidth = 1
)
View Source
const (
	Tag = "unixtable"
)

Variables

View Source
var ErrTypeNotSupported = errors.New("type not supported")

Functions

func Marshal

func Marshal(a any) ([]byte, error)

Types

type Encoder

type Encoder struct {
	*tabwriter.Writer
	// contains filtered or unexported fields
}

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(a any) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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