Golang beautify data display for Humans

Overview

Golang beautify data display for Humans

Build Status Go Report Card GoDoc GitHub license gocover.io

Install

# Stable version
go get -u -v gopkg.in/ffmt.v1

# Latest version
go get -u -v github.com/go-ffmt/ffmt

Usage

API Documentation

Examples

package main

import (
	ffmt "github.com/go-ffmt/ffmt"
)

func main() {
	example()
}

type mt struct {
	String string
	Int    int
	Slice  []int
	Map    map[string]interface{}
}

func example() {
	m := mt{
		"hello world",
		100,
		[]int{1, 2, 3, 4, 5, 6},
		map[string]interface{}{
			"A":  123,
			"BB": 456,
		},
	}

	fmt.Println(m) // fmt the default formatting.
	/*
		{hello world 100 [1 2 3 4 5 6] map[BB:456 A:123]}
	*/

	ffmt.Puts(m) // More friendly formatting.
	/*
		{
		 String: "hello world"
		 Int:    100
		 Slice:  [
		  1 2 3
		  4 5 6
		 ]
		 Map: {
		  "A":  123
		  "BB": 456
		 }
		}
	*/

	ffmt.Print(m) // Same "Puts" but String unadded '"'.
	/*
		{
		 String: hello world
		 Int:    100
		 Slice:  [
		  1 2 3
		  4 5 6
		 ]
		 Map: {
		  A:  123
		  BB: 456
		 }
		}
	*/

	ffmt.P(m) // Format data and types.
	/*
		main.mt{
		 String: string("hello world")
		 Int:    int(100)
		 Slice:  []int[
		  int(1) int(2) int(3)
		  int(4) int(5) int(6)
		 ]
		 Map: map[string]interface {}{
		  string("A"):  int(123)
		  string("BB"): int(456)
		 }
		}
	*/

	ffmt.Pjson(m) // Format it in json style.
	/*
		{
		 "Int": 100
		,"Map": {
		  "A":  123
		 ,"BB": 456
		 }
		,"Slice": [
		  1,2,3
		 ,4,5,6
		 ]
		,"String": "hello world"
		}
	*/

	m0 := ffmt.ToTable(m, m) // Break the fields into tables.
	ffmt.Puts(m0)
	/*
		[
		 [
		  "String" "Int"
		  "Slice"  "Map"
		 ]
		 [
		  "hello world"   "100"
		  "[1 2 3 4 5 6]" "map[A:123 BB:456]"
		 ]
		]
	*/

	m1 := ffmt.FmtTable(m0) // [][]string Table format.
	ffmt.Puts(m1)
	/*
		[
		 "String      Int Slice         Map               "
		 "hello world 100 [1 2 3 4 5 6] map[A:123 BB:456] "
		]
	*/

	ffmt.Mark("hello") // Mark position.
	/*
		main.go:124  hello
	*/

	ffmt.Print(ffmt.BytesViewer("Hello world! Hello All!"))
	/*
  |  Address | Hex                                             | Text             |
  | -------: | :---------------------------------------------- | :--------------- |
  | 00000000 | 48 65 6c 6c 6f 20 77 6f 72 6c 64 21 20 48 65 6c | Hello world! Hel |
  | 00000010 | 6c 6f 20 41 6c 6c 21                            | lo All!          |
	*/
}

License

Pouch is licensed under the MIT License. See LICENSE for the full license text.

Owner
ffmt
ffmt
A go driver for the adafruit I2C 7 Segment display

A go driver for the adafruit I2C 7 Segment display

Jackson Borneman 0 Nov 21, 2021
Exercise for solve problem data processing, performance and something wrong in passing data

Citcall Exercise Exercise for solve problem data processing, performance and something wrong in passing data Pengolahan data data processing - Readme

Muhammad Fazri 0 Nov 25, 2021
In one particular project, i had to import some key/value data to Prometheus. So i have decided to create my custom-built Node Exporter in Golang.

In one particular project, i had to import some key/value data to Prometheus. So i have decided to create my custom-built Node Exporter in Golang.

Hamid Hosseinzadeh 1 May 19, 2022
Random fake data and struct generator for Go.

Faker Random fake data and struct generator for Go. More than 100 generator functions Struct generator Unique data generator Builtin types support Eas

Enrico 62 May 23, 2022
Random fake data generator written in go

Gofakeit Random data generator written in go Features 160+ Functions!!! Concurrent Global Rand Struct Generator Custom Functions Http Server Command L

Brian Voelker 2.5k Jun 28, 2022
Gountries provides: Countries (ISO-3166-1), Country Subdivisions(ISO-3166-2), Currencies (ISO 4217), Geo Coordinates(ISO-6709) as well as translations, country borders and other stuff exposed as struct data.

gountries Inspired by the countries gem for ruby. Countries (ISO-3166-1), Country Subdivisions(ISO-3166-2), Currencies (ISO 4217), Geo Coordinates(ISO

Pär Karlsson 343 Jun 17, 2022
generate fake data in go

Faker for Go Usage package main import ( "github.com/manveru/faker" ) func main() { fake, err := faker.New("en") if err != nil { panic(err

Michael Fellinger 164 Jun 20, 2022
A toolkit for replaying time series data.

Replay Toolkit The replay package provides some simple tools for replaying captured data at realtime. I use this in various tools that take logged dat

Dustin Sallings 16 Aug 13, 2019
Self hosted search engine for data leaks and password dumps

Self hosted search engine for data leaks and password dumps. Upload and parse multiple files, then quickly search through all stored items with the power of Elasticsearch.

Davide Pataracchia 22 Aug 2, 2021
Go package providing tools for working with Library of Congress data.

go-libraryofcongress Go package providing tools for working with Library of Congress data. Documentation Tools $> make cli go build -mod vendor -o bin

San Francisco International Airport Museum 6 Oct 29, 2021
An effective time-series data compression/decompression method based on Facebook's Gorilla.

Gorilla This package provides the effective time-series data compression method based on Facebook's Gorilla.. In a nutshell, it uses delta-of-delta ti

Keisuke Umegaki 49 Jun 15, 2022
Go package for working with Library of Congress data in an SFO Museum context.

go-sfomuseum-libraryofcongress Go package for working with Library of Congress data in an SFO Museum context. Documentation Documentation is incomplet

San Francisco International Airport Museum 0 Oct 19, 2021
Crossjoin joins together your data from anywhere.

crossjoin Crossjoin joins together your data from anywhere. Supports PostgreSQL, Redshift, CSV data sources Zero dependency CLI, or a single Docker co

null 42 Feb 23, 2022
Experimental Monika After Story persistent data loader written in Go

Go Persistent Loader This project is an experiment on loading/deserializing Monika After Story persistent (save) file into memory. Currently it contai

Friends of Monika 2 May 10, 2022
Manage internal technical documentation that is enriched with live data accreted from your environment.

Manage internal technical documentation that is enriched with live data accreted from your environment.

Daniel Tedman 0 Dec 11, 2021
Api for getting blockchain data

This project contains 4 APIs. The users are stored in PostgreSql Database. Registering the user User Login Get Block

Asif Bhat 0 Nov 7, 2021
Generic mapStringInterface tool for extracting of data for CSV output

Generic mapStringInterface tool for extracting of data for CSV output

tbal999 1 Nov 2, 2021
Data interface for salesforce price bulk get

data-interface-for-salesforce-price-bulk-get 概要 data-interface-for-salesforce-price-bulk-get は、salesforce の価格オブジェクト取得に必要なデータの整形、および作成時に salesforce から返

Latona, Inc. 1 Nov 27, 2021
A comphrehensive tool for converting between data table formats

tblconv A simple tool for converting one "table" format into another. Supported Formats CSV source output Excel source output SQL source output CLI Fe

null 0 May 30, 2022