https://github.com/gonejack/linesprinter
Golang library to print string into fixed length lines
https://github.com/gonejack/linesprinter
Last synced: about 1 month ago
JSON representation
Golang library to print string into fixed length lines
- Host: GitHub
- URL: https://github.com/gonejack/linesprinter
- Owner: gonejack
- License: mit
- Created: 2021-11-19T06:27:44.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-13T03:18:08.000Z (about 4 years ago)
- Last Synced: 2024-10-09T09:27:58.981Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# linesprinter
golang library to print string into fixed length lines
### Usage
```shell
go get github.com/gonejack/linesprinter
```
Setting line length to 76 and sep as \r\n
```golang
func main() {
p := linesprinter.NewLinesPrinter(os.Stdout, 76, []byte("\r\n"))
defer p.Close()
w := base64.NewEncoder(base64.StdEncoding, p)
defer w.Close()
t := "this is some random string this is some random string this is some random string"
w.Write([]byte(t))
}
```
Output
```
dGhpcyBpcyBzb21lIHJhbmRvbSBzdHJpbmcgdGhpcyBpcyBzb21lIHJhbmRvbSBzdHJpbmcgdGhp
cyBpcyBzb21lIHJhbmRvbSBzdHJpbmc=
```