pad

package module
v0.0.0-...-172aa76 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: BSD-2-Clause Imports: 1 Imported by: 125 modules, 172 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

pad

Build Status

A golang implementation of the left-pad javascript library

I was inspired by Stew's left-cats, who was inspired by this article, to port this to Go.

This implementation will let you pad byte-strings and UTF-8 encoded strings

example usage:

package main

import (
	"fmt"

	"github.com/willf/pad"
	padUtf8 "github.com/willf/pad/utf8"
)

func main() {
	fmt.Println(pad.Right("Hello", 20, "!"))
	fmt.Println(padUtf8.Left("Exit now", 20, "→"))
}
> go run example.go
Hello!!!!!!!!!!!!!!!
→→→→→→→→→→→→Exit now

Documentation

Overview

Package pad provides left-padding functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Left

func Left(str string, length int, pad string) string

Left left-pads the string with pad up to len runes len may be exceeded if

func Right(str string, length int, pad string) string

Right right-pads the string with pad up to len runes

Types

This section is empty.

Directories

Path Synopsis
Package utf8 provides left-padding and right-padding for utf8 strings
Package utf8 provides left-padding and right-padding for utf8 strings

Jump to

Keyboard shortcuts

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