Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/spenserblack/go-wordwrap

Wraps words with a given limit
https://github.com/spenserblack/go-wordwrap

go golang word-wrap wordwrap

Last synced: about 1 month ago
JSON representation

Wraps words with a given limit

Awesome Lists containing this project

README

        

# `wordwrap`

[![CI](https://github.com/spenserblack/go-wordwrap/actions/workflows/ci.yml/badge.svg)](https://github.com/spenserblack/go-wordwrap/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/spenserblack/go-wordwrap/branch/master/graph/badge.svg?token=4SMgf9x2vv)](https://codecov.io/gh/spenserblack/go-wordwrap)
[![Go Report Card](https://goreportcard.com/badge/github.com/spenserblack/go-wordwrap)](https://goreportcard.com/report/github.com/spenserblack/go-wordwrap)
[![Go Reference](https://pkg.go.dev/badge/github.com/spenserblack/go-wordwrap.svg)](https://pkg.go.dev/github.com/spenserblack/go-wordwrap)

Wraps words at a given limit. Wraps at whitespace, hyphens (`-`), and will wrap words that exceed
the given limit. See package documentation for more details.

## Example

```go
lines := wordwrap.WordWrap("this test-string has been successfully wrapped successfully", 10)
for _, line := range lines {
fmt.Println(line)
}
```

### Output

```console
this test-
string has
been
successful
ly wrapped
successful
ly
```