Skip to content

fix: include v2 in go module path #303

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

Merged
merged 3 commits into from
Feb 9, 2021
Merged

fix: include v2 in go module path #303

merged 3 commits into from
Feb 9, 2021

Conversation

vbrown608
Copy link
Contributor

@vbrown608 vbrown608 commented Feb 5, 2021

Ookay so, I failed to consider that in Go, versions after v1 need to have the version included in their module path.

The Go Team suggests achieving this by copying all the v2 code into a v2 subdirectory. I dislike this approach because the most recent version of the module isn't in the repo root. In our case, it would be extra confusing because this repo is also used for Swagger and Js client. That means we would have v2/go, so the most up-to-date go directory would be hidden and the rest of the files in the root would still be about v2 of Swagger and Js. Orrr we could put those under v2 as well, but no one from the JS world is going to expect that.

The Go Team recommends this because the module path is going to match the file structure, so imports without Go modules are still going to work. However, as Go progresses fewer people are using old versions that don't use go modules so will be less of a problem.

The other suggested option is to create a v2 branch. However, we don't really need our v1 code to exist alongside our v2 code - it's very unlikely that we're going to make a fix to v1, we're almost certainly just going to apply it to v2 an expect that users will use that version. And, we're still going to have the problem of making it look good with the Swagger and Js side.

So, I'm taking the third option which is just to append v2 to the end of the module path. If works well and keeps the branching and directory structure clean. Thoughts welcome from others with strong opinions about Go modules, I just formed mine today 😁

The official Go explanation of this situation is hard to scan, I recommend https://donatstudios.com/Go-v2-Modules

@vbrown608 vbrown608 requested a review from a team as a code owner February 5, 2021 00:25
@netlify
Copy link

netlify bot commented Feb 5, 2021

Deploy preview for open-api ready!

Built with commit 7a831bb

https://deploy-preview-303--open-api.netlify.app

@vbrown608 vbrown608 added the type: chore work needed to keep the product and development running smoothly label Feb 5, 2021
@github-actions github-actions bot added the type: bug code to address defects in shipped code label Feb 5, 2021
@vbrown608 vbrown608 removed the type: chore work needed to keep the product and development running smoothly label Feb 5, 2021
@@ -12,12 +12,9 @@ require (
github.com/go-openapi/validate v0.20.0
github.com/go-swagger/go-swagger v0.23.0
github.com/kyoh86/richgo v0.3.3
github.com/mitchellh/mapstructure v1.4.0 // indirect
Copy link
Contributor

Choose a reason for hiding this comment

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

memo: this is just from go mod tidy

Copy link
Contributor

@keiko713 keiko713 left a comment

Choose a reason for hiding this comment

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

I like this option the best too, so looks good to me 👍

@vbrown608 vbrown608 merged commit ccbb8cd into master Feb 9, 2021
@vbrown608 vbrown608 deleted the set-go-module-path branch February 9, 2021 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants