Skip to content

Commit

Permalink
Add Apple M1 Build Arch (& other arm64) (#28)
Browse files Browse the repository at this point in the history
* Update `gox` call in the Makefile to:
    * include arch: arm64
    * remove arch: 386
    * Explicitly include `-osarch="linux/386" -osarch="windows/386`
* Specify Go v1.16 in CI config
* add a go.mod
* Add a comment to exported Replacement struct
* gofmt -s -w search-replace_test.go
  • Loading branch information
jblz committed Feb 24, 2021
1 parent d99c5b4 commit 175fa99
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: go

go:
- 1.13.x
- 1.16.x
- master

install:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/automattic/go-search-replace

go 1.16
1 change: 1 addition & 0 deletions search-replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions search-replace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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,
},
Expand Down Expand Up @@ -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,
},
Expand All @@ -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"),
},
Expand All @@ -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"),
},
Expand Down

0 comments on commit 175fa99

Please sign in to comment.