leftpad

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2018 License: BSD-2-Clause Imports: 2 Imported by: 1

README

left-pad

Go package to left pad a string with a character.

Inspired by the "left-pad" NPM package (and the fiasco that happened after its removal).

Build status

Branch: master —

Install
go get github.com/keltia/leftpad 
Usage

GoDoc

import "github.com/keltia/leftpad"

leftpad.Pad("foo", 5)    // "  foo"
leftpad.Pad("foobar", 8) // "  foobar"
leftpad.Pad("foobar", 6) // "foobar"

leftpad.PadChar("foo", 5, 'X') // "XXfoo"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pad

func Pad(s string, n int) (string, error)

Pad left-pads s with spaces, to length n. If n is smaller than s, Pad is a no-op.

func PadChar

func PadChar(s string, n int, r rune) (string, error)

PadChar left-pads s with the rune r, to length n. If n is smaller than s, PadChar is a no-op.

Types

This section is empty.

Jump to

Keyboard shortcuts

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