Skip to content

chore: add /v2 to import module path #9037

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

Closed
wants to merge 2 commits into from
Closed

chore: add /v2 to import module path #9037

wants to merge 2 commits into from

Conversation

coryb
Copy link
Contributor

@coryb coryb commented Aug 11, 2023

go mod requires semantic versioning with versions greater than 1.x

This was a mechanical update by running:

go install github.com/marwan-at-work/mod/cmd/mod@latest
mod upgrade

@cdr-bot cdr-bot bot added the community Pull Requests and issues created by the community. label Aug 11, 2023
@github-actions
Copy link

github-actions bot commented Aug 11, 2023

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


1 out of 2 committers have signed the CLA.
@kylecarbs
@coryb
You can retrigger this bot by commenting recheck in this Pull Request

@coryb coryb changed the title add /v2 to import module path chore: add /v2 to import module path Aug 11, 2023
@coryb
Copy link
Contributor Author

coryb commented Aug 11, 2023

Not sure how to sign the CLA. We have a corporate CLA for Netflix.

go mod requires semantic versioning with versions greater than 1.x

This was a mechanical update by running:
```
go install github.com/marwan-at-work/mod/cmd/mod@latest
mod upgrade
```
@matifali
Copy link
Member

@coryb you have to type a comment with

I have read the CLA Document and I hereby sign the CLA

@Emyrk
Copy link
Member

Emyrk commented Aug 11, 2023

Do we need this right now?

For the go mod requires semantic versioning with versions greater than 1.x, we are only on v2.x.x to remove any possible confusion with our first version of the product. Semantically, we are on v1.x.x of this repository, but for business reasons, we jump to v2.x.x.

The first version of the product is closed source, so for go module reasons, the two products will never be confused externally.


Additional question,

Does this mean that anyone importing github.com/coder/coder might get our v0.x.x version of the code, and not the latest?

@Emyrk
Copy link
Member

Emyrk commented Aug 11, 2023

Reading https://go.dev/ref/mod#major-version-suffixes

If an old package and a new package have the same import path, the new package must be backwards compatible with the old package.

I will defer judgment to others, but these imports are backwards compatible to the previous v0.x.x. I think the only package that is created for external use is the codersdk package.

@Emyrk
Copy link
Member

Emyrk commented Aug 11, 2023

I am not blocking this PR btw, just curious

@coryb
Copy link
Contributor Author

coryb commented Aug 11, 2023

If an old package and a new package have the same import path, the new package must be backwards compatible with the old package.

I think this only refers to releases within the same major version stream.

That document also says:

Starting with major version 2, module paths must have a major version suffix like /v2 that matches the major version. For example, if a module has the path example.com/mod at v1.0.0, it must have the path example.com/mod/v2 at version v2.0.0.

and

By definition, packages in a new major version of a module are not backwards compatible with the corresponding packages in the previous major version.

I am pretty fuzzy on the go.mod version requirements myself, I just know that we cant import the latest coder release because it fails:

go get github.com/coder/coder@v2.0.2
go: github.com/coder/coder@v2.0.2: invalid version: module contains a go.mod file, so module path must match major version ("github.com/coder/coder/v2")
go get github.com/coder/coder/v2@v2.0.2
go: github.com/coder/coder@v2.0.2: invalid version: module contains a go.mod file, so module path must match major version ("github.com/coder/coder/v2")

Anyway, it looks like the PR doesn't work because of several other places where the package name is hard-coded in generators. I fixed the protos and some locations in ./scripts, but there seem to be more. I need to fix my dev environment to run these things locally so probably makes sense for someone else to recreate this work, or patch my PR.

@Emyrk
Copy link
Member

Emyrk commented Aug 11, 2023

I am pretty fuzzy on the go.mod version requirements myself, I just know that we cant import the latest coder release because it fails:

go get github.com/coder/coder@v2.0.2
go: github.com/coder/coder@v2.0.2: invalid version: module contains a go.mod file, so module path must match major version ("github.com/coder/coder/v2")
go get github.com/coder/coder/v2@v2.0.2
go: github.com/coder/coder@v2.0.2: invalid version: module contains a go.mod file, so module path must match major version ("github.com/coder/coder/v2")

Ooof this is enough validation for me. We have a few generators yea 😢

@kylecarbs
Copy link
Member

Doing #9072 instead

@coryb
Copy link
Contributor Author

coryb commented Aug 14, 2023

closing in favor of #9072

@coryb coryb closed this Aug 14, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Aug 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community Pull Requests and issues created by the community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants