marwan-at-work / Mod

Licence: mit
Automated Semantic Import Versioning Upgrades

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Labels

Projects that are alternatives of or similar to Mod

Pnpm
Fast, disk space efficient package manager -- 快速的,节省磁盘空间的包管理工具
Stars: ✭ 14,219 (+6452.53%)
Mutual labels:  modules
Httpimport
Module for remote in-memory Python package/module loading through HTTP/S
Stars: ✭ 153 (-29.49%)
Mutual labels:  modules
Bit
A tool for component-driven application development.
Stars: ✭ 14,443 (+6555.76%)
Mutual labels:  modules
Registry
Components as records of functions for Haskell
Stars: ✭ 132 (-39.17%)
Mutual labels:  modules
Yorn
⚗️ Modules in PHP with the `import` and `export` syntax
Stars: ✭ 141 (-35.02%)
Mutual labels:  modules
Android Clean Architecture
Showcasing a Clean Architecture approach from our Android applications framework!
Stars: ✭ 160 (-26.27%)
Mutual labels:  modules
Annotation Processing Example
It is the example project for the annotation processing tutorial.
Stars: ✭ 116 (-46.54%)
Mutual labels:  modules
Videoplayback Ios
Swift AVPlayer wrapper using the VIPER architecture. Currently a work in progress
Stars: ✭ 213 (-1.84%)
Mutual labels:  modules
Vuex Namespaced Module Structure
📈 A Vue.js project powered by Vuex namespaced modules in a simple structure based on Large-scale Vuex application structures
Stars: ✭ 146 (-32.72%)
Mutual labels:  modules
M2
The primary source code repository for Macaulay2, a system for computing in commutative algebra, algebraic geometry and related fields.
Stars: ✭ 200 (-7.83%)
Mutual labels:  modules
Practical Server Side Swift
Vapor 4 code samples for the Practical Server Side Swift book
Stars: ✭ 133 (-38.71%)
Mutual labels:  modules
Kube Aws Iam Controller
Distribute different AWS IAM credentials to different pods in Kubernetes via secrets.
Stars: ✭ 137 (-36.87%)
Mutual labels:  modules
L5modular
Generates and handles Modules for Laravel
Stars: ✭ 188 (-13.36%)
Mutual labels:  modules
Spring Boot Quick
🌿 基于springboot的快速学习示例,整合自己遇到的开源框架,如:rabbitmq(延迟队列)、Kafka、jpa、redies、oauth2、swagger、jsp、docker、spring-batch、异常处理、日志输出、多模块开发、多环境打包、缓存cache、爬虫、jwt、GraphQL、dubbo、zookeeper和Async等等📌
Stars: ✭ 1,819 (+738.25%)
Mutual labels:  modules
Browserify
browser-side require() the node.js way
Stars: ✭ 13,929 (+6318.89%)
Mutual labels:  modules
Sun
Android-Sun-Framework 模块化开发框架
Stars: ✭ 123 (-43.32%)
Mutual labels:  modules
Ndash
your npm dashboard! (react-native app)
Stars: ✭ 158 (-27.19%)
Mutual labels:  modules
Minipack
📦 A simplified example of a modern module bundler written in JavaScript
Stars: ✭ 2,625 (+1109.68%)
Mutual labels:  modules
Gitpkg
Publish packages as git tags
Stars: ✭ 208 (-4.15%)
Mutual labels:  modules
Beginners Python Examples
Basic Python CLI programs
Stars: ✭ 190 (-12.44%)
Mutual labels:  modules

Mod

Command line tool to upgrade/downgrade Semantic Import Versioning in Go Modules

Motivation

There are two good use cases to do this:

  1. If you own a library and you want to introduce a breaking change, then you have to go around all your Go files and sub-packages and update the import paths to include v2, v3, etc. This tool just does it automatically with one command.

  2. If you own a library that is already tagged v2 or above but is incompatible with Semantic Import Versioning, then this tool can solve the problem for you with one command as well. Introduce a go.mod file with the correct import path, and just run mod upgrade once or mod -t=X upgrade (where x is the latest tag major) to update the import paths of your go files to match whatever tag you're at.

Install

GO111MODULE=on go get github.com/marwan-at-work/mod/cmd/mod

Usage

mod upgrade OR mod downgrade from any directory that has go.mod file.

The tool will update the major version in the go.mod file and it will traverse all the Go Files and upgrades/downgrades any imports as well.

For example, if you have the following package:

// go.mod

module github.com/me/example

require github.com/pkg/errors v0.8.0

that imports a sub directory in its Go files:

// example.go

package example

import (
    "github.com/me/example/subdir"
)

// rest of file...

You can run mod upgrade from the root of that directory and the above two files will be rewritten as such:

module github.com/me/example/v2

require github.com/pkg/errors
package example

import (
    "github.come/me/example/v2/subdir"
)

// rest of file...

You can of course, downgrade again or upgrade more incrementally.

You can also run this command inside the example folder and notice how the import paths and the module name alike get updated.

Upgrading a dependency

Say you are using a dependency like github.com/x/y/v2 and you want to use the new major version they just released. You don't want to change your own import paths, but you want to change the import paths of a dependency you're using from v2 to v3.

All you have to do is

mod upgrade --mod-name=github.com/x/y

Status

Works as intended. Feel free to report any issues.

Troubleshooting

If you are using iTerm2 and see this error:

<html><head></head><body><p><em>Error:</em> Your request has found no candidate provider [hs="(null)", id="(null)"]</p></body</html>

Make sure you close iTerm2 and start again. See https://github.com/marwan-at-work/mod/issues/3 for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].