Giter VIP home page Giter VIP logo

Comments (5)

jordan-wright avatar jordan-wright commented on June 30, 2024 2

Hi there!

Thanks for sending this in. This is something I've been aware of for some time, just haven't gotten time to fix. So let's chat about it 😄

The Go docs suggest:

Note that if you are adopting modules for the first time for a pre-existing repository or set of packages that have already been tagged v2.0.0 or higher before adopting modules, then the recommended best practice is to increment the major version when first adopting modules. For example, if you are the author of foo, and the latest tag for the foo repository is v2.2.2, and foo has not yet adopted modules, then the best practice would be to use v3.0.0 for the first release of foo to adopt modules (and hence the first release of foo to contain a go.mod file).

This is why I'd lean towards doing the following:

  • Changing the module in the go.mod to include /v5.
  • Tagging a new v5.0.0 release

This should get modules working where v5.0.0. While there may be some issues with certain clients like dep, it feels like it's the correct and most simple approach to more proper module support.

What do you think?

from email.

KateGo520 avatar KateGo520 commented on June 30, 2024

@JensRantil @l-ross Could you help me review this issue? Thx :p

from email.

KateGo520 avatar KateGo520 commented on June 30, 2024

@jordan-wright Thank you for your reply.
You can see your downstream repos through this link:
https://github.com/search?l=Go&q=github.com%2Fjordan-wright%2Femail&type=Code

And your downstream module user can be seen here:
https://github.com/search?q=github.com%2Fjordan-wright%2Femail+extension%3Amod&type=Code

Downstream repos that use dep、glide and so on, can be seen here:
https://github.com/search?q=github.com%2Fjordan-wright%2Femail+extension%3Ajson+extension%3Aconf+extension%3Atoml+extension%3Alock&type=Code

If you want to be compatible with all the downstream, maybe you could consider using one of two options:

  1. Delete the go.mod file when you send a commit.
  2. Create the repo using the "Major subdirectory" method

Major subdirectory: Create a new v3 subdirectory (e.g., my/module/v3) and place a new go.mod file in that subdirectory. The module path must end with /v3. Copy or move the code into the v3 subdirectory. Update import statements within the module to also use /v3 (e.g., import "github.com/my/module/v3/mypkg"). Tag the release with v3.0.0.

  • This provides greater backwards-compatibility. In particular, Go versions older than 1.9.7 and 1.10.3 are also able to properly consume and build a v2+ module created using this approach.
  • A more sophisticated approach here could exploit type aliases (introduced in Go 1.9) and forwarding shims between major versions residing in different subdirectories. This can provide additional compatibility and allow one major version to be implemented in terms of another major version but would entail more work for a module author. An in-progress tool to automate this is goforward. Please see here for more details and rationale, along with a functioning initial version of goforward.
  • Pre-existing dependency management solutions such as dep should be able to consume a v2+ module created in this way.

from email.

KateGo520 avatar KateGo520 commented on June 30, 2024

@jordan-wright
The "mixed" dependency management modes (GOPATH and Go modules) in the Go ecosysem can cause tons of issues.
Having a global view of your downstream and upstream projects and their migration situations (to Go Modules) can help you select a better solution by making a trade-off analysis, which aims to avoid introducing breaking changes into other projects in the community :p

Do you agree with the above opinion?

Hope my provided information about your downstream and upstream projects are useful.

Thanks again.

Best regards.

from email.

jordan-wright avatar jordan-wright commented on June 30, 2024

Hi @KateGo520,

Thanks for all the great feedback. I've opted to take the easy way out here for now and just removed the go.mod file. In the future, I'll consider a different option when I'm ready to cut a new major release.

from email.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.