olog

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2020 License: Apache-2.0 Imports: 2 Imported by: 2

README

olog

Welcome to olog! This is a table printing library for Go. It takes any array of structs and assembles an ascii box around the objects. This logger is not meant for large amount of data and instead should be used only on smaller arrays.

Installation

To download the library, simply run:

$ go get github.com/da0x/golang/olog

To import olog in your code, use:

import "github.com/da0x/golang/olog"
Example

Here is an example of how to use olog:

type Data struct {
	Name  string
	Age   int
	Score float32
}

func main() {
	var data = []Data{
		Data{Name: "John Smith", Age: 30, Score: 100.0},
		Data{Name: "Jane Smith", Age: 30, Score: 100.0},
	}
	olog.Print(data)        // same as PrintWithStyle(data, olog.Normal)
	olog.PrintStrong(data)  // same as PrintWithStyle(data, olog.Strong)
	olog.PrintVStrong(data) // same as PrintWithStyle(data, olog.VStrong)
	olog.PrintHStrong(data) // same as PrintWithStyle(data, olog.HStrong)
}

The above example prints the following output:

┌──────────┬───┬─────┐
│Name      │Age│Score│
├──────────┼───┼─────┤
│John Smith│30 │100  │
│Jane Smith│30 │100  │
└──────────┴───┴─────┘
╔══════════╦═══╦═════╗
║Name      ║Age║Score║
╠══════════╬═══╬═════╣
║John Smith║30 ║100  ║
║Jane Smith║30 ║100  ║
╚══════════╩═══╩═════╝
╓──────────╥───╥─────╖
║Name      ║Age║Score║
╟──────────╫───╫─────╢
║John Smith║30 ║100  ║
║Jane Smith║30 ║100  ║
╙──────────╨───╨─────╜
╒══════════╤═══╤═════╕
│Name      │Age│Score│
╞══════════╪═══╪═════╡
│John Smith│30 │100  │
│Jane Smith│30 │100  │
╘══════════╧═══╧═════╛
Maintainer

Daher Alfawares

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Clear = Style{
	// contains filtered or unexported fields
}

Clear is a thin bordered table.

View Source
var HStrong = Style{
	// contains filtered or unexported fields
}

StrongHorizantal is a slim border with a double lined horizantal borders.

View Source
var Markdown = Style{
	// contains filtered or unexported fields
}

Markdown is a thin bordered table.

View Source
var Normal = Style{
	// contains filtered or unexported fields
}

Normal is a thin bordered table.

View Source
var Strong = Style{
	// contains filtered or unexported fields
}

Strong is a double lined table.

View Source
var VStrong = Style{
	// contains filtered or unexported fields
}

StrongVertical is a slim border with a double lined vertical borders.

Functions

func Print

func Print(rows interface{})

func PrintClear added in v0.1.2

func PrintClear(rows interface{})

func PrintHStrong

func PrintHStrong(rows interface{})

func PrintMarkdown added in v0.1.2

func PrintMarkdown(rows interface{})

func PrintStrong

func PrintStrong(rows interface{})

func PrintVStrong

func PrintVStrong(rows interface{})

func PrintWithStyle

func PrintWithStyle(rows interface{}, s Style)

Types

type Style

type Style struct {
	// contains filtered or unexported fields
}

Style represents the table structure in 4 strings. 't' for top. 'm' for middle. 's' for seperator. 'b' for bottom. ┌─┬┐ ╔═╦╗ ╓─╥╖ ╒═╤╕ │ ││ ║ ║║ ║ ║║ │ ││ ├─┼┤ ╠═╬╣ ╟─╫╢ ╞═╪╡ └─┴┘ ╚═╩╝ ╙─╨╜ ╘═╧╛ ┌───────────────────┐ │ ╔═══╗ Some Text │▒ │ ╚═╦═╝ in the box │▒ ╞═╤══╩══╤═══════════╡▒ │ ├──┬──┤ │▒ │ └──┴──┘ │▒ └───────────────────┘▒

▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

https://en.wikipedia.org/wiki/Box-drawing_character

type StyleRow

type StyleRow struct {
	// contains filtered or unexported fields
}

Style row represents one row of a style. b for begining. m for middle. i for intersection. e for end.

Jump to

Keyboard shortcuts

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