From 50c7d4b28eea7a5cb3dc922cfe67ae4f0b893f65 Mon Sep 17 00:00:00 2001 From: Oliver Steele Date: Sat, 15 Jul 2017 21:25:35 -0400 Subject: [PATCH] TIL io.WriteString --- pipelines/sass.go | 2 +- server/taginjector_test.go | 3 ++- utils/html.go | 2 +- utils/ioutil_test.go | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pipelines/sass.go b/pipelines/sass.go index d3b068e..8a4eca8 100644 --- a/pipelines/sass.go +++ b/pipelines/sass.go @@ -83,6 +83,6 @@ func (p *Pipeline) WriteSass(w io.Writer, b []byte) error { if err != nil { return err } - _, err = w.Write([]byte(s)) + _, err = io.WriteString(w, s) return err } diff --git a/server/taginjector_test.go b/server/taginjector_test.go index d6c9502..86e53b2 100644 --- a/server/taginjector_test.go +++ b/server/taginjector_test.go @@ -2,6 +2,7 @@ package server import ( "bytes" + "io" "testing" "github.com/stretchr/testify/require" @@ -17,7 +18,7 @@ func TestTagInjector(t *testing.T) { for _, test := range tests { out := new(bytes.Buffer) w := TagInjector{out, []byte(":insertion:")} - _, err := w.Write([]byte(test.in)) + _, err := io.WriteString(w, test.in) require.NoError(t, err) require.Equal(t, test.out, out.String()) } diff --git a/utils/html.go b/utils/html.go index 463a96b..53bd67f 100644 --- a/utils/html.go +++ b/utils/html.go @@ -28,7 +28,7 @@ outer: } case html.TextToken: if body { - s := (string(z.Text())) + s := string(z.Text()) _, err := buf.WriteString(fn(s)) if err != nil { panic(err) diff --git a/utils/ioutil_test.go b/utils/ioutil_test.go index a98c8cd..d6e66e3 100644 --- a/utils/ioutil_test.go +++ b/utils/ioutil_test.go @@ -56,7 +56,7 @@ func TestVisitCreatedFile(t *testing.T) { err = f.Close() require.NoError(t, err) err = VisitCreatedFile(f.Name(), func(w io.Writer) error { - _, e := w.Write([]byte("test")) + _, e := io.WriteString(w, "test") return e }) require.NoError(t, err)