Skip to content
Node: s.padEnd(n, ch)github.com/sahilkhaire/gox/str

PadEnd

Overview

PadEnd pads s on the right to length with pad (String.padEnd).

If you are coming from Node.js, the closest pattern is s.padEnd(n, ch).

Signature

go
func PadEnd(s string, length int, pad string) string

Compare: Node.js · Standard Go · gox

js
s.padEnd(8, '-');
go
s = fmt.Sprintf("%*s", width, s) // or custom padding
go
import "github.com/sahilkhaire/gox/str"

s := str.PadEnd("go", 8, "-")

Example

go
import "github.com/sahilkhaire/gox/str"

s := str.PadEnd("go", 8, "-")

Tips

Import github.com/sahilkhaire/gox/str and call PadEnd directly. See the comparison below for the standard library equivalent.

Standard library alternative

Use the standard library directly:

go
s = fmt.Sprintf("%*s", width, s) // or custom padding

Back to str package overview

MIT Licensed · Built for Node.js developers moving to Go