tablelize

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: MIT Imports: 2 Imported by: 1

README

tablelize

Test

Prints out the values of a table (array of arrays) of strings aligned by width. It also tries to align numbers to the right if all are numeric.

Usage
package main

import (
    "github.com/jpedro/tablelize"
)

func main() {
    var data [][]any

    data = append(data, []any{"KEY", "VALUE", "NUMBER", "ALMOST_NUMBER"})
    data = append(data, []any{"char", "a", "1", "1"})
    data = append(data, []any{"longer-key-name", "Some text", "-2", "2"})
    data = append(data, []any{"key", "And now for something completely different", "3", "3a"})

    tablelize.Rows(data)
}

Output:

% go run example/main.go
KEY               VALUE                                        NUMBER   ALMOST_NUMBER
char              a                                                 1   1
longer-key-name   Some text                                        -2   2
key               And now for something completely different        3   3a

Check example/main.go.

Documentation

Index

Constants

View Source
const (
	ALIGN_STRING int = iota
	ALIGN_NUMBER
)

Variables

This section is empty.

Functions

func Print

func Print(data [][]any)

Prints the table.

func Render

func Render(data [][]any) string

Returns the rendered table.

func Rows deprecated

func Rows(data [][]any)

Deprecated: Use `tablelize.Print` instead.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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