diff --git a/.travis.yml b/.travis.yml index f9eb47f..86258dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: go go: - - 1.13.x + - 1.16.x - master install: diff --git a/Makefile b/Makefile index c48f5da..8a91f2c 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ all: vet fmt lint test build build: clean which gox > /dev/null || go get -u github.com/mitchellh/gox - gox -os="linux" -os="darwin" -os="windows" -arch="amd64" -arch="386" -output="${BUILDDIR}/${BINARY}_{{.OS}}_{{.Arch}}" + gox -os="darwin" -os="linux" -os="windows" -arch="amd64" -arch="arm64" -osarch="linux/386" -osarch="windows/386" -output="${BUILDDIR}/${BINARY}_{{.OS}}_{{.Arch}}" gzip build/* vet: diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..95bccff --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/automattic/go-search-replace + +go 1.16 diff --git a/search-replace.go b/search-replace.go index 37839fe..67dab0e 100644 --- a/search-replace.go +++ b/search-replace.go @@ -32,6 +32,7 @@ var ( bad = regexp.MustCompile(badInputRe) ) +// Replacement has two fields (both byte slices): "From" & "To" type Replacement struct { From []byte To []byte diff --git a/search-replace_test.go b/search-replace_test.go index 029dbc5..91945dd 100644 --- a/search-replace_test.go +++ b/search-replace_test.go @@ -18,7 +18,7 @@ func BenchmarkSimpleReplace(b *testing.B) { to := []byte("https:") for i := 0; i < b.N; i++ { replaceAndFix(&line, []*Replacement{ - &Replacement{ + { From: from, To: to, }, @@ -32,7 +32,7 @@ func BenchmarkSerializedReplace(b *testing.B) { to := []byte("https://automattic.com") for i := 0; i < b.N; i++ { replaceAndFix(&line, []*Replacement{ - &Replacement{ + { From: from, To: to, }, @@ -98,7 +98,7 @@ func TestReplace(t *testing.T) { for _, test := range tests { t.Run(test.testName, func(t *testing.T) { replaced := replaceAndFix(&test.in, []*Replacement{ - &Replacement{ + { From: test.from, To: test.to, }, @@ -123,11 +123,11 @@ func TestMultiReplace(t *testing.T) { in: []byte("http://automattic.com"), out: []byte("https://automattic.org"), replacements: []*Replacement{ - &Replacement{ + { From: []byte("http:"), To: []byte("https:"), }, - &Replacement{ + { From: []byte("automattic.com"), To: []byte("automattic.org"), }, @@ -138,11 +138,11 @@ func TestMultiReplace(t *testing.T) { in: []byte("http://automattic.com"), out: []byte("https://automattic.org"), replacements: []*Replacement{ - &Replacement{ + { From: []byte("http:"), To: []byte("https:"), }, - &Replacement{ + { From: []byte("//automattic.com"), To: []byte("//automattic.org"), },