diff --git a/hclwrite/ast.go b/hclwrite/ast.go index 7620b83..7e6c336 100644 --- a/hclwrite/ast.go +++ b/hclwrite/ast.go @@ -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) diff --git a/hclwrite/round_trip_test.go b/hclwrite/round_trip_test.go index 1a00731..a498bba 100644 --- a/hclwrite/round_trip_test.go +++ b/hclwrite/round_trip_test.go @@ -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 { diff --git a/hclwrite/tokens.go b/hclwrite/tokens.go index 0b2034a..d37b1c6 100644 --- a/hclwrite/tokens.go +++ b/hclwrite/tokens.go @@ -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