hclwrite: Make File and Tokens implement io.WriterTo
There isn't any strong reason for this -- they don't implement io.Reader and so can't be used in places where a Reader+WriterTo is expected, like io.Copy -- but go lint thinks that anything called WriteTo with an io.Writer argument is an attempt to implement WriterTo and so this just shuts up the linter.
This commit is contained in:
parent
fd915f557d
commit
a44a287724
@ -22,7 +22,7 @@ func (f *File) Body() *Body {
|
||||
//
|
||||
// The tokens first have a simple formatting pass applied that adjusts only
|
||||
// the spaces between them.
|
||||
func (f *File) WriteTo(wr io.Writer) (int, error) {
|
||||
func (f *File) WriteTo(wr io.Writer) (int64, error) {
|
||||
tokens := f.inTree.children.BuildTokens(nil)
|
||||
format(tokens)
|
||||
return tokens.WriteTo(wr)
|
||||
|
@ -60,7 +60,7 @@ block {
|
||||
|
||||
wr := &bytes.Buffer{}
|
||||
n, err := file.WriteTo(wr)
|
||||
if n != len(test) {
|
||||
if n != int64(len(test)) {
|
||||
t.Errorf("wrong number of bytes %d; want %d", n, len(test))
|
||||
}
|
||||
if err != nil {
|
||||
|
@ -51,7 +51,7 @@ func (ts Tokens) Columns() int {
|
||||
// WriteTo takes an io.Writer and writes the bytes for each token to it,
|
||||
// along with the spacing that separates each token. In other words, this
|
||||
// allows serializing the tokens to a file or other such byte stream.
|
||||
func (ts Tokens) WriteTo(wr io.Writer) (int, error) {
|
||||
func (ts Tokens) WriteTo(wr io.Writer) (int64, error) {
|
||||
// We know we're going to be writing a lot of small chunks of repeated
|
||||
// space characters, so we'll prepare a buffer of these that we can
|
||||
// easily pass to wr.Write without any further allocation.
|
||||
@ -60,7 +60,7 @@ func (ts Tokens) WriteTo(wr io.Writer) (int, error) {
|
||||
spaces[i] = ' '
|
||||
}
|
||||
|
||||
var n int
|
||||
var n int64
|
||||
var err error
|
||||
for _, token := range ts {
|
||||
if err != nil {
|
||||
@ -74,7 +74,7 @@ func (ts Tokens) WriteTo(wr io.Writer) (int, error) {
|
||||
}
|
||||
var thisN int
|
||||
thisN, err = wr.Write(spaces[:thisChunk])
|
||||
n += thisN
|
||||
n += int64(thisN)
|
||||
if err != nil {
|
||||
return n, err
|
||||
}
|
||||
@ -82,7 +82,7 @@ func (ts Tokens) WriteTo(wr io.Writer) (int, error) {
|
||||
|
||||
var thisN int
|
||||
thisN, err = wr.Write(token.Bytes)
|
||||
n += thisN
|
||||
n += int64(thisN)
|
||||
}
|
||||
|
||||
return n, err
|
||||
|
Loading…
Reference in New Issue
Block a user