Skip to content

Commit

Permalink
Merge pull request #15 from Eric-Warehime/golang-1.17-upgrade
Browse files Browse the repository at this point in the history
Golang 1.17 upgrade
  • Loading branch information
Eric-Warehime committed May 9, 2022
2 parents 69c487e + 9f06576 commit 998a2ac
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ msgp/cover.out
*~
*.coverprofile
.idea/
cover.out
11 changes: 3 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
# Installation can still be performed with a
# normal `go install`.

# generated integration test files
GGEN = ./_generated/generated.go ./_generated/generated_test.go
# generated unit test files
MGEN = ./msgp/defgen_test.go

Expand All @@ -20,28 +18,25 @@ $(BIN): */*.go

install: $(BIN)

$(GGEN): ./_generated/def.go
go generate ./_generated

$(MGEN): ./msgp/defs_test.go
go generate ./msgp

test: all
go test ./... ./_generated
go test -covermode=atomic -coverprofile=cover.out ./...

bench: all
go test -bench ./...

clean:
$(RM) $(GGEN) $(MGEN)
$(RM) $(MGEN)

wipe: clean
$(RM) $(BIN)

get-deps:
go get -d -t ./...

all: install $(GGEN) $(MGEN)
all: install $(MGEN)

# travis CI enters here
travis:
Expand Down
7 changes: 6 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
module github.com/algorand/msgp

go 1.16
go 1.17

require (
github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31
golang.org/x/tools v0.0.0-20200423205358-59e73619c742
)

require (
golang.org/x/mod v0.2.0 // indirect
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect
)
2 changes: 1 addition & 1 deletion printer/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,6 @@ func writeImportHeader(b *bytes.Buffer, imports ...string) {
}

func writeBuildHeader(b *bytes.Buffer, buildHeaders []string) {
headers := fmt.Sprintf("// +build %s\n\n", strings.Join(buildHeaders, " "))
headers := fmt.Sprintf("//go:build %s\n// +build %s\n\n", strings.Join(buildHeaders, " "), strings.Join(buildHeaders, " "))
b.WriteString(headers)
}
19 changes: 19 additions & 0 deletions printer/print_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package printer

import (
"bytes"
"testing"
)

func TestWriteBuildHeader(t *testing.T) {
testBuf := bytes.NewBuffer(make([]byte, 0, 4096))
buildHeaders := []string{"foobar"}
expectedBuf := bytes.NewBuffer(make([]byte, 0, 4096))
expectedBuf.WriteString("//go:build foobar\n// +build foobar\n\n")

writeBuildHeader(testBuf, buildHeaders)

if testBuf.String() != expectedBuf.String() {
t.Errorf("testBuf:\n%s not equal to expectedBuf:\n%s", testBuf, expectedBuf)
}
}

0 comments on commit 998a2ac

Please sign in to comment.