Giter Site home page Giter Site logo

Comments (3)

dolmen avatar dolmen commented on May 18, 2024

There is a reason why the Go team doesn't provides a package to edit go.mod: the official go.mod editing API is go mod edit.

So gohack should just use go mod edit commands instead of editing the file itself.

from gohack.

mvdan avatar mvdan commented on May 18, 2024

Beware that gohack came out very early in the timeline of modules, before tools like go mod edit were fully developed.

Also, note that there is in fact a package to parse and print go.mod files: https://pkg.go.dev/golang.org/x/mod/modfile

from gohack.

dolmen avatar dolmen commented on May 18, 2024

The fact is that you have to keep in sync the version of your Go toolchain with any other tools that have go.mod editing capabilities.

For gohack to maintain compability with Go toolchain upgrades:

  • the gohack maintainers have to keep to go.mod editing editing in sync with the toolchain (and that doesn't happen: the fact that github.com/rogpeppe/go-internal/modfile hasn't been updated for 2 years just shows that doesn't work)
  • the end user has to update gohack when (s)he updates the toolchain with a gohack that has upgraded its go.mod support.

That isn't sustainable.

golang.org/x/mod/modfile can help to solve the first point (but that would still require that the gohack maintainers to upgrade the dependency in case of a new go.mod format change), but that will never fix the second point.

So go mod edit is the only sustainable way.

from gohack.

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.