Update vendor/
This commit is contained in:
24
vendor/github.com/emersion/go-textwrapper/.gitignore
generated
vendored
Normal file
24
vendor/github.com/emersion/go-textwrapper/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
1
vendor/github.com/emersion/go-textwrapper/.travis.yml
generated
vendored
Normal file
1
vendor/github.com/emersion/go-textwrapper/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
language: go
|
21
vendor/github.com/emersion/go-textwrapper/LICENSE
generated
vendored
Normal file
21
vendor/github.com/emersion/go-textwrapper/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 emersion
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
27
vendor/github.com/emersion/go-textwrapper/README.md
generated
vendored
Normal file
27
vendor/github.com/emersion/go-textwrapper/README.md
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
# go-textwrapper
|
||||
|
||||
[](https://godoc.org/github.com/emersion/go-textwrapper)
|
||||
[](https://travis-ci.org/emersion/go-textwrapper)
|
||||
|
||||
A writer that wraps long text lines to a specified length
|
||||
|
||||
## Usage
|
||||
|
||||
```go
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/emersion/go-textwrapper"
|
||||
)
|
||||
|
||||
func main() {
|
||||
w := textwrapper.New(os.Stdout, "/", 5)
|
||||
|
||||
w.Write([]byte("helloworldhelloworldhelloworld"))
|
||||
// Output: hello/world/hello/world/hello/world
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
61
vendor/github.com/emersion/go-textwrapper/wrapper.go
generated
vendored
Normal file
61
vendor/github.com/emersion/go-textwrapper/wrapper.go
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
// A writer that wraps long text lines to a specified length.
|
||||
package textwrapper
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
type writer struct {
|
||||
Sep string
|
||||
Len int
|
||||
|
||||
w io.Writer
|
||||
i int
|
||||
}
|
||||
|
||||
func (w *writer) Write(b []byte) (N int, err error) {
|
||||
to := w.Len - w.i
|
||||
|
||||
for len(b) > to {
|
||||
var n int
|
||||
n, err = w.w.Write(b[:to])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
N += n
|
||||
b = b[to:]
|
||||
|
||||
_, err = w.w.Write([]byte(w.Sep))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
w.i = 0
|
||||
to = w.Len
|
||||
}
|
||||
|
||||
w.i += len(b)
|
||||
|
||||
n, err := w.w.Write(b)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
N += n
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Returns a writer that splits its input into multiple parts that have the same
|
||||
// length and adds a separator between these parts.
|
||||
func New(w io.Writer, sep string, l int) io.Writer {
|
||||
return &writer{
|
||||
Sep: sep,
|
||||
Len: l,
|
||||
w: w,
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a RFC822 text wrapper. It adds a CRLF (ie. \r\n) each 76 characters.
|
||||
func NewRFC822(w io.Writer) io.Writer {
|
||||
return New(w, "\r\n", 76)
|
||||
}
|
Reference in New Issue
Block a user