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 1.11 module support #39

Merged
merged 3 commits into from
May 3, 2019
Merged

Go 1.11 module support #39

merged 3 commits into from
May 3, 2019

Conversation

talbright
Copy link
Contributor

@talbright talbright commented Dec 23, 2018

MODULE SUPPORT

Go 1.11 includes preliminary support for versioned modules as proposed here. Modules are an experimental opt-in feature in Go 1.11, with the hope of incorporating feedback and finalizing the feature for Go 1.12. Even though the details may change, future releases will support modules defined using Go 1.11 or vgo.

This PR drops the v3 path. For detailed discussion see comments in this PR.

This PR continues support for vendoring for older versions of GO (https://github.com/golang/go/wiki/Modules#how-do-i-use-vendoring-with-modules-is-vendoring-going-away)

Older versions of Go such as 1.10 understand how to consume a vendor directory created by go mod vendor, so vendoring is one way to provide dependencies to older versions of Go that do not fully understand modules.

TODO

  • Determine vendoring approach
  • Update docs
  • Improve build with Makefile(s) which: will be invoked by travis instead of go test and include appropriate checks such as gofmt
  • Update travis to build 1.9 - 1.12 (https://docs.travis-ci.com/user/customizing-the-build/#build-matrix)
  • Minor improvements to schema generation script and inclusion of generation target in makefile

⭐️ After merging be sure to create a github release
⭐️ Use semver and github releases moving forward

Addresses #37

@talbright talbright changed the title Go 1.11 module support [WIP] Go 1.11 module support Dec 23, 2018
@talbright talbright changed the title [WIP] Go 1.11 module support Go 1.11 module support Dec 24, 2018
@cyberdelia
Copy link
Contributor

For the record, v3 was meant to match the API version more than indicating the version of the “library” itself.

@alindeman
Copy link
Contributor

For the record, v3 was meant to match the API version more than indicating the version of the “library” itself.

I think this is important. Is there any way we can make this project compatible with modules without bumping to v4?

@talbright
Copy link
Contributor Author

Unfortunately v1, v2, ... in GO projects has a special meaning that doesn't seem to be related to the use case here (https://github.com/golang/go/wiki/Modules#semantic-import-versioning) and is causing some conflicts with the new module system.

I can work on a different approach but that may reduce compatibility. Is that a preferred tradeoff?

@mars
Copy link
Member

mars commented Jan 3, 2019

Unfortunately v1, v2, ... in GO projects has a special meaning that doesn't seem to be related to the use case here

😬 wow that's a collision of intents for sure.

I always assumed that v3 indicated the Heroku API v3, but if it's conflated with Go import versioning, perhaps we should rename that troubled module path to version3 or api-v3 as part of this major change.

@talbright
Copy link
Contributor Author

😬 wow that's a collision of intents for sure.

I always assumed that v3 indicated the Heroku API v3, but if it's conflated with Go import versioning, perhaps we should rename that troubled module path to version3 or api-v3 as part of this major change.

The main concern I have with doing that (or my preference -- flattening the directory structure), is breaking existing users. I would be less concerned if there had been releases/tagging.

What's the purpose of this pattern? Is it really needed? This client does not utilize variants, so it's always the official supported API "latest GA". Does Heroku (or has it ever) supported multiple GA versions of its platform API?

@mars
Copy link
Member

mars commented Jan 4, 2019

Before merging any module system changes, let's definitely please 🙏 make a release containing the current "pre-go-modules" client.

I'm happy to go ahead with that, call it v1.0.0 to kick-off our semantic versioning, and clearly describe the release as the "Initial stable release before switching to the new Go 1.11 modules system".

@fgblomqvist
Copy link

Any update on this? Also, any recommended way of importing the package (as it currently is) into a go mod project?

Right now, the only way I can get working is to require github.com/heroku/heroku-go v0.0.0-20190103224148-ad17585a922f and then import github.com/heroku/heroku-go/v3 inside my code. Doesn't seem like the proper way. I tried doing a replace github.com/heroku/heroku-go => github.com/heroku/heroku-go/v3 latest which seemed to initially work (it would tag it as v3.0.0.....) but then it just complained about not finding a go.mod in the root or in the v3. But yeah, this is the first package I've dealt with that uses the directory structure-way of versioning it.

@talbright
Copy link
Contributor Author

@fgblomqvist I'm waiting to here back from the team...

@alindeman @cyberdelia any thoughts? Happy to make changes to this PR if there's a preferred approach.

@mars
Copy link
Member

mars commented Mar 27, 2019

I created our first release 🙀 v1.0.0.

We'll move forward with this likely breaking PR soon.

@mars
Copy link
Member

mars commented Mar 28, 2019

Hey @talbright ,

Let's drop /v3 from the module path so usage becomes:

It will be a breaking change of course. We'll tag it as v2.0.0, and add an obvious Breaking Change notice to the README.

(See revision to plan in next comment.)

Does anything else need to happen to resolve the problem using this as a Go Module?

Let me know if you have time to work on this, or if it would be helpful for me to take it from here 😇

@mars
Copy link
Member

mars commented Mar 28, 2019

Apparently I have not read enough Go Module documentation. (Thanks to friendly collaborators pointing this out.)

According to "Go Modules: Semantic Import Versioning" docs we don't have an option:

If the module is version v2 or higher, the major version of the module must be included as a /vN at the end of the module paths used in go.mod files (e.g., module github.com/my/mod/v2, require github.com/my/mod/v2 v2.0.0) and in the package import path (e.g., import "github.com/my/mod/v2/mypkg").

The current version will actually need to be tagged v3.0.0 (done), and the new Go Modules version will need its path to be changed to /v4 and tagged v4.0.0.

@talbright
Copy link
Contributor Author

Hey @talbright ,

Let's drop /v3 from the module path so usage becomes:

It will be a breaking change of course. We'll tag it as v2.0.0, and add an obvious Breaking Change notice to the README.

(See revision to plan in next comment.)

Does anything else need to happen to resolve the problem using this as a Go Module?

Let me know if you have time to work on this, or if it would be helpful for me to take it from here 😇
I can follow through and finish up. There's some other nice changes for the build on the branch I want to make sure don't get lost as well.

I will review that doc again (its been a few months.) From what I recall though, if we aren't worried about breaking backwards compatibility we do have the option of dropping vN. I somewhat prefer this approach:

  • it removes the vN vestiges and naming convention for which I'm not a fan of
  • simplifies module support going forward
  • makes the code base easier to maintain

In the future if Heroku truly needs to maintain two separate versions of the API (the original reason the vN notation was used), likely the best thing to do is create a new project for it.

@mars
Copy link
Member

mars commented Mar 29, 2019

Sounds great @talbright

@talbright talbright force-pushed the mod-compat branch 2 times, most recently from e819a6c to 501330d Compare April 21, 2019 02:18
@talbright
Copy link
Contributor Author

@mars ready for review

@mars
Copy link
Member

mars commented Apr 24, 2019

Nice @talbright! 🙌😄 I'll review and test how it works with the Terraform Provider next week.

Copy link
Member

@mars mars left a comment

Choose a reason for hiding this comment

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

Thanks for your patience as I finally got to this. Just a few comments in-line.

Also, I opened a PR on the Terraform Provider that uses this branch:

  • validated that this Provider branch works correctly with Terraform, applying & destroying a simple configuration
  • currently running the full Provider test suite locally (will report back, but it's all success so far)

README.md Outdated Show resolved Hide resolved
@@ -1 +1,7 @@
language: go

go:
- "1.9"
Copy link
Member

Choose a reason for hiding this comment

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

Are Go Modules backward-compatible? These CI versions might need some pruning.

Copy link
Contributor Author

@talbright talbright May 3, 2019

Choose a reason for hiding this comment

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

Not exactly no. But vendoring is the magic that makes this work. Please see https://github.com/golang/go/wiki/Modules#how-do-i-use-vendoring-with-modules-is-vendoring-going-away for more details. Also note the matrix is building all these versions just fine so things seem to line up.

Co-Authored-By: talbright <[email protected]>
@talbright
Copy link
Contributor Author

talbright commented May 3, 2019

Thanks for your patience as I finally got to this. Just a few comments in-line.

No worries, this PR is just taking its time to germinate. We will get there.

Also, I opened a PR on the Terraform Provider that uses this branch:

* validated that this Provider branch works correctly with Terraform, applying & destroying a simple configuration

* currently running the full Provider test suite locally (will report back, but it's all success so far)

Awesome, thanks for doing this.

@mars
Copy link
Member

mars commented May 3, 2019

✅ Hashicorp CI passed for the Terraform Provider on this branch.

@talbright
Copy link
Contributor Author

w00t! BTW I don't have perms to merge...

@mars mars merged commit 8096b47 into heroku:master May 3, 2019
@mars
Copy link
Member

mars commented May 3, 2019

I'm releasing v4.0.0 now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants