...

Text file src/github.com/mitchellh/go-wordwrap/README.md

Documentation: github.com/mitchellh/go-wordwrap

     1# go-wordwrap
     2
     3`go-wordwrap` (Golang package: `wordwrap`) is a package for Go that
     4automatically wraps words into multiple lines. The primary use case for this
     5is in formatting CLI output, but of course word wrapping is a generally useful
     6thing to do.
     7
     8## Installation and Usage
     9
    10Install using `go get github.com/mitchellh/go-wordwrap`.
    11
    12Full documentation is available at
    13http://godoc.org/github.com/mitchellh/go-wordwrap
    14
    15Below is an example of its usage ignoring errors:
    16
    17```go
    18wrapped := wordwrap.WrapString("foo bar baz", 3)
    19fmt.Println(wrapped)
    20```
    21
    22Would output:
    23
    24```
    25foo
    26bar
    27baz
    28```
    29
    30## Word Wrap Algorithm
    31
    32This library doesn't use any clever algorithm for word wrapping. The wrapping
    33is actually very naive: whenever there is whitespace or an explicit linebreak.
    34The goal of this library is for word wrapping CLI output, so the input is
    35typically pretty well controlled human language. Because of this, the naive
    36approach typically works just fine.
    37
    38In the future, we'd like to make the algorithm more advanced. We would do
    39so without breaking the API.

View as plain text