format

package
v0.0.0-...-90445b8 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package format helps formatting various data types

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoPluralize

func AutoPluralize(quantity int, qualifier string) string

AutoPluralize pluralizes words automatically

Example
fmt.Println(AutoPluralize(2, "child"))
Output:

2 children

Types

type AutoPluralizer

type AutoPluralizer struct {
	Quantity  int
	Qualifier string
}

AutoPluralizer implements fmt.Stringer interface and pluralizes words automatically

Example
fmt.Printf("Jack has %s and Tom has %s.", AutoPluralizer{1, "candy"}, AutoPluralizer{2, "candy"})
Output:

Jack has 1 candy and Tom has 2 candies.

func (AutoPluralizer) String

func (c AutoPluralizer) String() string

type RelTime

type RelTime struct {
	Time time.Time
}

RelTime implements fmt.Stringer interface and formats a time.Time into a relative value

Example
t := RelTime{time.Now().Add(-5 * time.Minute)}
fmt.Println(t)
Output:

5 minutes ago
Example (Future)
t := RelTime{time.Now().Add(5 * time.Minute)}
fmt.Println(t)
Output:

5 minutes from now

func (RelTime) String

func (c RelTime) String() string

Jump to

Keyboard shortcuts

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