Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Golang 1.17 upgrade #15

Merged
merged 4 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the failure that made it so this needed to be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume there will be a lot of them. The code these tests use was ripped out. For example, https://github.com/algorand/msgp/blob/master/_generated/convert_test.go#L13
uses https://github.com/tinylib/msgp/blob/43b487371e0cdd1a3fe1be9a7802d8bce917a1af/msgp/write.go#L118 from the original repository which was removed from our fork in this commit 546fb5f

# 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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this in a separate require block? did go mod tidy create it this way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it was from running tidy. I left it that way since I liked the fact that direct deps were being separated from indirect. Not aware of whether this is a convention or something we don't do in other repos.

)
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)
}
}