Merge pull request #1688 from mtrmac/ReplaceAll

Use bytes.ReplaceAll instead of bytes.Replace(..., -1)
This commit is contained in:
Daniel J Walsh
2022-07-01 07:03:11 -04:00
committed by GitHub

View File

@@ -166,7 +166,7 @@ func fileFromFixture(c *check.C, inputPath string, edits map[string]string) stri
contents, err := os.ReadFile(inputPath)
c.Assert(err, check.IsNil)
for template, value := range edits {
updated := bytes.Replace(contents, []byte(template), []byte(value), -1)
updated := bytes.ReplaceAll(contents, []byte(template), []byte(value))
c.Assert(bytes.Equal(updated, contents), check.Equals, false, check.Commentf("Replacing %s in %#v failed", template, string(contents))) // Verify that the template has matched something and we are not silently ignoring it.
contents = updated
}