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

go: Add Go modules support #486

Merged
merged 3 commits into from
May 15, 2020
Merged

go: Add Go modules support #486

merged 3 commits into from
May 15, 2020

Conversation

chfast
Copy link
Member

@chfast chfast commented Dec 12, 2019

Go modules support by @mandrigin.

Closes #450

@codecov-io
Copy link

Codecov Report

Merging #486 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #486   +/-   ##
=======================================
  Coverage   91.14%   91.14%           
=======================================
  Files          20       20           
  Lines        2970     2970           
=======================================
  Hits         2707     2707           
  Misses        263      263

go.mod Outdated Show resolved Hide resolved
go.mod Outdated
@@ -0,0 +1,3 @@
module github.com/ethereum/evmc/v7

go 1.14
Copy link
Member

Choose a reason for hiding this comment

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

The readme say "Go (bindings) | 1.9 - 1.12". Is this changing that?

Copy link
Collaborator

Choose a reason for hiding this comment

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

you can still build it on the old golang, but go modules will require go 1.14

I can adjust README

Copy link
Collaborator

@mandrigin mandrigin May 14, 2020

Choose a reason for hiding this comment

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

updated the readme file

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what this mean, but this works in Go 1.11 (the first version that supports modules).

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed that to 1.11 as some random comment on internet this is minimum Go version of the module.

@mandrigin
Copy link
Collaborator

mandrigin commented May 14, 2020

turbo-geth code that uses this PR: https://github.com/ledgerwatch/turbo-geth/tree/evmc-upstream/

@mandrigin mandrigin marked this pull request as ready for review May 14, 2020 14:26
@@ -0,0 +1,3 @@
module github.com/ethereum/evmc/v7
Copy link
Member Author

Choose a reason for hiding this comment

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

So it is enough to only declare it as "v7" here but use dir structure unchanged?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, it seems so

@@ -15,6 +15,8 @@ package evmc
#include <stdlib.h>
#include <string.h>

#include "loader/loader.c"
Copy link
Member Author

Choose a reason for hiding this comment

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

I think this should be a problem because the C comment in go files are compiled twice if any Go function is exported. I think it only works because there is nothing exported here.
I may have modified version of this, will try to push it there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It misses some definitions w/o that import for some reason... At least on a mac.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed that.

@chfast chfast added the changelog Deserves a CHANGELOG entry label May 14, 2020
@chfast
Copy link
Member Author

chfast commented May 14, 2020

I pushed some additions, including an integration test for Go module.

Copy link
Collaborator

@mandrigin mandrigin left a comment

Choose a reason for hiding this comment

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

looks good!

@@ -0,0 +1,3 @@
module github.com/ethereum/evmc/v7
Copy link
Member

Choose a reason for hiding this comment

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

Why is there a need for v7 here? If we bump to ABI 8 and this is changed to v8, will go modules still be able to download v7 things?

Or the only benefit is knowing it is v7 even if someone uses a commithash after it?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is required by go mod. The vX is required if you version is vX.Y.Z. Can be only omitted if X==1 || X==0.

Versions are marked with git tags, and v7 series will continue to work (because e.g. at v7.3.0 this line will be still module github.com/ethereum/evmc/v7.

The usage is something like this:

go get github.com/ethereum/evmc/v7@v7.3.0
go get github.com/ethereum/evmc/v7@v7.3.1
go get github.com/ethereum/evmc/v8@v8.0.0

And also

import "github.com/ethereum/evmc/v7"
import "github.com/ethereum/evmc/v8"

So users need to update their import directives when upgrading major version number. In case of EVMC where vX matches ABI version this is reasonable IMHO.

Copy link
Member

@axic axic May 15, 2020

Choose a reason for hiding this comment

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

So it is just a convention required by go mod, it won't magically make v7 work when we move on to v8, because it still just downloads from the repo master, unless a commit hash is specified, correct? Or are the versions used as git tags?

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. go get github.com/ethereum/evmc/v7@v8.0.0 will fail due to mismatch.
  2. go get github.com/ethereum/evmc/v7@master will also fail if the most recent version is v8.Y.Z. go mod uses a kind of git describe strategy to figure out the "current" version.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good.

@@ -0,0 +1,3 @@
module github.com/ethereum/evmc/v7
Copy link
Member

Choose a reason for hiding this comment

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

Maybe in a future PR, one could update bumpversion to also update this line.

@axic
Copy link
Member

axic commented May 15, 2020

Do we have documentation on the bindings? I don't think we have them yet, but maybe we should, where example uses could be explained.

Copy link
Member

@axic axic left a comment

Choose a reason for hiding this comment

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

Looks good to me, except those two small comments.

@chfast
Copy link
Member Author

chfast commented May 15, 2020

Do we have documentation on the bindings? I don't think we have them yet, but maybe we should, where example uses could be explained.

We don't have any Go documentation. The standard Go packages documentation hosting is https://pkg.go.dev/. For general documentation migration to readthedocs would be nice.

@chfast chfast merged commit 81d4941 into master May 15, 2020
@chfast chfast deleted the gomod branch May 15, 2020 09:56
@chfast chfast added the go label May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog Deserves a CHANGELOG entry go
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Go modules
4 participants