Code Monkey home page Code Monkey logo

gomajor's Introduction

GOMAJOR

A tool for major version upgrades

Installation

go install github.com/icholy/gomajor@latest

Commands

  • get - Upgrade to a major version
  • list - List available updates
  • path - Modify the module path

Usage format is as follows: gomajor <command> [arguments]

Usage

List Updates

gomajor list

Update a module to its latest version

gomajor get github.com/go-redis/redis@latest

Switch a module to a specific version

gomajor get github.com/go-redis/redis@v7

Update all mobules to their latest version

gomajor get all

Increment module path version

gomajor path -next

Change module path version

gomajor path -version v3

Change module path

gomajor path goredis.io

Warning:

  • This tool does not understand replace directives or nested modules.
  • By default, only cached content will be fetched from the module proxy (See -cached flag).
  • If you have multiple major versions imported, ALL of them will be rewritten.
  • The latest version will not be found if there are gaps between major version numbers.
  • The path command does not rewrite package names.
  • Modules matching GOPRIVATE are skipped.

gomajor's People

Contributors

atrox avatar icholy avatar wtrocki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gomajor's Issues

allow using "get" on all updates shown by "list"

If gomajor list shows me a few updates, either minor or major version bumps, it would be nice to be able to use gomajor get with those directly. Perhaps there's a way, but I haven't found one via the help docs, so I manually copy-paste the new module paths into gomajor get.

Perhaps gomajor get all?

Add -alias flag to auto-add replace directive

Nice tool.

I was thinking .. as you’ve seen discussion at 44550, I need to try it, but a replace of a SIV to one without may help bandaid the experience I’m suggesting in that proposal. What if this tool had -alias which you could pass a package name without SIV and it would add replace to alias. Then could add -alias-all to alias every module without passing a specific one.. and maybe -alias-skip too for exclusion.

I usually use Makefiles, so something like that could be used to manage an experience similar to what I’m describing in 44550. What do you think?

Cc @zikaeroh

gomajor get github.com/go-redis/redis/v8 gets wrong version

I ran the following:

gomajor get github.com/go-redis/redis/v8
go get github.com/go-redis/redis
go: github.com/go-redis/redis upgrade => v6.15.9+incompatible
bridge/adapters/sources/redis.go: github.com/go-redis/redis/v8 -> github.com/go-redis/redis
bridge/adapters/targets/redis.go: github.com/go-redis/redis/v8 -> github.com/go-redis/redis

Instead of getting the latest version of v8, it downloaded v6.15.9+incompatible

Support replaced modules

The kubernonsense go.mod uses replace to pin their dependencies. This bad technique has leaked into repositories which extend kubernetes. I think we can support this use-case with the following 2 behaviours.

  1. Don't skip replaced modules in gomajor list
  2. If a required module is replaced with the exact same version, gomajor get will update both the required and and replaced version.

Rewriting k8s.io/apiserver to k8s.io/api/server

Running gomajor get k8s.io/api@latest inside the kubernetes repository results in k8s.io/apiserver/* import paths being rewritten to k8s.io/api/server/* paths. This appears to be a bug in the internal/packages.SplitPath function.

filter out major upgrades to incompatible versions by default

In a few projects, I see gomajor list -major make suggestions like:

github.com/libp2p/go-libp2p: v0.21.0 [latest v6.0.23+incompatible]
github.com/mattn/go-sqlite3: v1.14.16 [latest v2.0.3+incompatible]

The suggestions are technically correct, because the upgrades are indeed newer major versions, and they aren't retracted via the modules system.

However, they're wrong: they are older versions which were published either before switching to Go modules, or by mistake.

I reckon that gomajor list -major should, by default, ignore major version upgrades which add the +incompatible component. An upgrade from v2.0.0+incompatible to v3.0.0+incompatible would be shown by default, because it's not making anything worse, but v1.0.0 to v3.0.0+incompatible would not be shown by default, with the understanding that often it will be a bad idea. Nowadays, if a module really does bump their major version, it's incredibly rare that they will publish as +incompatible.

One could still get the old behavior via a flag, like -incompatible.

Add move command for moving packages

Add a move command for moving packages in a module.

$ gomajor move pkg/foo internal/bar

Behaviour:

  • Move the directory
  • Change the package declaration.
  • Rewrite import paths.

Provide a linter

Are there any plans to also provide a golangci-lint compatible linter that reports new major versions?

Go Major does not work with private repos

I'm looking at gomajor to evaluate when I need to update versions and for public repo's it's fine. However for private repo's it does not list them.
Is this something that is planned for the future.

My envvar GOPRIVATE is already set correctly.

failed: no module versions found

I ran gomajor list -major in terraformer and got a lot of failed: no module versions found errors:

$ gomajor list -major
cloud.google.com/go/iam: v0.13.0 [latest v1.1.6]
github.com/Azure/azure-sdk-for-go: v63.4.0+incompatible [latest v68.0.0+incompatible]
github.com/IBM-Cloud/bluemix-go: failed: no module versions found
github.com/IBM-Cloud/container-services-go-sdk: failed: no module versions found
github.com/IBM/go-sdk-core/v4: v4.9.0 [latest v5.15.3]
github.com/IBM/go-sdk-core/v3: v3.3.1 [latest v5.15.3]
github.com/IBM/vpc-go-sdk: v0.4.1 [latest v1.0.2]
github.com/OctopusDeploy/go-octopusdeploy: v1.6.0 [latest v2.38.3]
github.com/apache/openwhisk-client-go: failed: no module versions found
github.com/ddelnano/terraform-provider-mikrotik/client: failed: no module versions found
github.com/ddelnano/terraform-provider-xenorchestra/client: failed: no module versions found
github.com/denverdino/aliyungo: failed: no module versions found
github.com/fastly/go-fastly/v7: v7.0.0 [latest v9.0.0]
github.com/hashicorp/hcl: v1.0.0 [latest v2.20.0]
github.com/hashicorp/terraform: v0.12.31 [latest v1.7.4]
github.com/heimweh/go-pagerduty: failed: no module versions found
github.com/hashicorp/vault: v0.10.4 [latest v1.15.6]
github.com/labd/commercetools-go-sdk: v0.3.1 [latest v1.5.0]
github.com/linode/linodego: v0.24.1 [latest v1.29.0]
github.com/google/go-github/v35: v35.1.0 [latest v60.0.0]
github.com/mrparkers/terraform-provider-keycloak: failed: no module versions found
github.com/microsoft/azure-devops-go-api/azuredevops: failed: no module versions found
github.com/okta/terraform-provider-okta: failed: no module versions found
github.com/newrelic/newrelic-client-go: v0.79.0 [latest v2.26.1]
github.com/okta/okta-sdk-golang/v2: v2.12.2-0.20220602195034-d7ea6917663f [latest v4.0.0]
github.com/yandex-cloud/go-genproto: failed: no module versions found
github.com/yandex-cloud/go-sdk: failed: no module versions found
github.com/vultr/govultr: v1.1.1 [latest v3.6.4]
google.golang.org/genproto: failed: no module versions found
k8s.io/client-go: v0.24.2 [latest v1.5.2]

Add command for changing the current module path

I've seen some people using the get sub-command to rewrite imports when incrementing their module's major version. There should be a dedicated command for that use-case. This command will update go.mod and rewrite all imports in the module.

Examples:

// increment the major version
gomajor path -next

// specify the version to use the path
gomajor path -version v5

// specify the whole path to use
gomajor path "github.com/icholy/gomajor/v10"

Feat: add apidiff subcommand

The apidiff subcommand will be a more ergonomic interface to the x/exp/apidiff package.

Show the apidiff between two import paths

gomajor apidiff github.com/deckarep/[email protected]  github.com/deckarep/golang-set@v2
  • this works outside of a module.
  • if only one path is provided, the other is inferred from your go.mod.

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.