pstrings

package
v0.4.171 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: ISC Imports: 4 Imported by: 3

Documentation

Overview

Package pstrings provides string fitting, filtered join and quoting of a string slice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilteredJoin

func FilteredJoin(sList []string, separator ...string) (line string)

FilteredJoin is like strings.Join but ignores empty strings. defauklt separator is single space \x20

func FilteredJoinWithHeading added in v0.4.28

func FilteredJoinWithHeading(sList []string, separator ...string) (line string)

FilteredJoinWithHeading takes a string slice of heading-value pairs and only outputs those strings that are non-empty. {"head1", "first", "head2, ""} → "head1: first"

func Fit added in v0.4.30

func Fit(s string, width int, pad bool) (s2 string)

Fit return a string fitted to certain column width

  • if width < 1, no change
  • if s’ length equals width, no change
  • if s’ length less than width, pad with spaces if pad true, otherwise no change
  • otherwise cut s in the center and replace with single epsilon "…" character

func FitValueAndLabel added in v0.4.34

func FitValueAndLabel(width int, value, label string, pad bool) (s string)

fitValueAndLabel trums a value and its label to fit into width

  • if pad is true and result shorter than width, s is padded with spaces to reach width

func IsDefaultValue

func IsDefaultValue(pt interface{}) (isDefault bool)

func QuoteList

func QuoteList(strs []string) string

QuoteList formats a string slice using %q into a single space-separated string

func StrSliceContains

func StrSliceContains(ss []string, s string) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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