Go implementation of the "left-pad" package, inspired by the NPM package of the same [in]famous name.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore Add basic gitignore. Mar 23, 2016
.travis.yml Move to 1.10. Feb 17, 2018
LICENSE Basic files, BSD 2-clauses license. Mar 23, 2016
README.md Fix README Mar 29, 2016
go.mod Sync. Aug 15, 2018
leftpad.go Remove nonidiomatic doc comments Mar 29, 2016
leftpad_test.go 100% coverage. May 28, 2017

README.md

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 — master|Build Status

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"