go mod tidy, but for multi-module monorepos via mad science

monotidy

go mod tidy, but for multi-module monorepos

Why?

In a multi-module monorepo, when dependabot updates a shared lib's go.mod, this also invalidates the go.sum of all the dependent applications in the same repo (if they use a replace directive for the local relative path), so then go mod verify will fail for those dependents, breaking the build without manual intervention.

Ideally, when we update a shared library directory, we would then run go mod tidy on all the dependent (e.g. application) modules, and commit back the changed go.sum files.

This can be done with a dumb little bash script:

/dev/null } function modupdate { for D in */; do if [ -f "${D}go.mod" ]; then echo -e "\033[32m\xE2\x9c\x93 Updating modules for ${D}\n\n\033[0m" rm "./${D}go.sum" # cat "./${D}go.mod" | grep 'go 1.' # list go version cd "${D}" #go get -u all # ! is_bin_in_path go-mod-upgrade && go get -u github.com/oligot/go-mod-upgrade #is_bin_in_path go-mod-upgrade && go-mod-upgrade go mod tidy # go mod download # go mod verify # go vet ./... cd .. fi done } ">
 #!/bin/bash

 # uncommenting below will update all the go modules, and show you if the go.mod is targetting
 # old go versions. Requires go-mod-upgrade

function is_bin_in_path {
  builtin type -P "$1" &> /dev/null
}

function modupdate {
    for D in */; do
        if [ -f "${D}go.mod" ]; then
            echo -e "\033[32m\xE2\x9c\x93 Updating modules for ${D}\n\n\033[0m"
            rm "./${D}go.sum"
            # cat "./${D}go.mod" | grep 'go 1.' # list go version
            cd "${D}"
            #go get -u all
            # ! is_bin_in_path go-mod-upgrade && go get -u github.com/oligot/go-mod-upgrade
            #is_bin_in_path go-mod-upgrade && go-mod-upgrade
            go mod tidy
            # go mod download
            # go mod verify
            # go vet ./...
            cd ..
        fi
    done
}

However, that assumes we have a whole unix environment and Golang dev tools, which bloats the size of any CI container and slows down the whole process.

I want juuuuuust go mod tidy, but from a root directory on all go.mod file containing subdirectories, so I can make a static binary to shove in a scratch container.

Luckily, github's dependabot helpfully scrapes and copies the go tools internal packages and renames them so they are re-usable, so I can reuse them!

Then, I can just hook dependabot up to THIS repo, and it will maintain itself. Muhahahahaha!

insert further mad science here

Owner
Steve Coffman
•ა꧁シ He / Him シ꧂ა• 【ツ】⬆️
Steve Coffman
Similar Resources

Remake of the original sqlifinder but in GOlang, and allows for listed targets, domain crawling, and tor connections

Remake of the original sqlifinder but in GOlang, and allows for listed targets, domain crawling, and tor connections

_______ _____ _____ _______ _____ __ _ ______ _______ ______ |______ | __| | | |______ | | \ | | \ |______ |_____/

Jan 4, 2023

Coral, a friendly Cobra fork with nearly all its features, but only 4 dependencies

Coral, a friendly Cobra fork with nearly all its features, but only 4 dependencies

Coral Preamble I love Cobra and I love Viper. They are great projects, incredibly useful and outstandingly important for the Go community. But sometim

Dec 29, 2022

Jezziki-webapp - Discontinued but finished web app utilizing a golang backend and reactjs frontend

jezziki-webapp discontinued but finished web app utilizing a golang backend and

Feb 12, 2022

Just Enough C2 - A simple but effective server and implant

Just Enough C2 An opinionated C2 server and implant which does Just Enough to be effective. Meant primarily for small teams operating on small numbers

Dec 1, 2022

Multi-threaded socks proxy checker written in Go!

Soxy - a very fast tool for checking open SOCKS proxies in Golang I was looking for some open socks proxies, and so I needed to test them - but really

Sep 6, 2022

httpx is a fast and multi-purpose HTTP toolkit allows to run multiple probers using retryablehttp library, it is designed to maintain the result reliability with increased threads.

httpx is a fast and multi-purpose HTTP toolkit allows to run multiple probers using retryablehttp library, it is designed to maintain the result reliability with increased threads.

Features • Installation • Usage • Running httpx • Notes • Join Discord httpx is a fast and multi-purpose HTTP toolkit allow to run multiple probers us

Jan 8, 2023

Cross-platform, multi-server chat app built using Fyne

Cross-platform, multi-server chat app built using Fyne

Fibro Really early days proof of concept for a cross-platform multi-server chat. Feel free to play, but don't expect it to do much! Features Multiple

Sep 10, 2022

Easily increment 📶 a multi-language 🔱 project version

 Easily increment 📶 a multi-language 🔱 project version

version-bump Have you ever made a mistake incrementing a project version? Do you have multiple files to update the version at? I was always forgetting

Dec 14, 2022

Multi-platform presence sharing

What's My Status? What's my status? is a command line utility that allows you to set your status on multiple platforms at once. Installation To instal

Sep 6, 2022
Comments
  • Participate in go.work discussion

    Participate in go.work discussion

    https://github.com/golang/go/issues/45713 is an active proposal to add multiple module support to Go via a “go.work” workspace file. Please file your use cases and feedback in the issue.

  • Confusing basic condition

    Confusing basic condition

    A multi-module repo that uses replace directives to point imports to the same checkout seems to me to defeat the purpose of having more than one module in the repo. Doubly so given that replace directives are meant to be temporary. Can you give an example repo that this tool is meant to operate against?

Related tags
llb - It's a very simple but quick backend for proxy servers. Can be useful for fast redirection to predefined domain with zero memory allocation and fast response.

llb What the f--k it is? It's a very simple but quick backend for proxy servers. You can setup redirect to your main domain or just show HTTP/1.1 404

Sep 27, 2022
An imageboard, but images are stored in a peer-to-peer network
An imageboard, but images are stored in a peer-to-peer network

Interplanetary File Dumpster An imageboard, but images are stored in a peer-to-peer network Features: Easy file sharing without registration and SMS.

Sep 30, 2022
A suite of gRPC debugging tools. Like Fiddler/Charles but for gRPC.

grpc-tools A suite of tools for gRPC debugging and development. Like Fiddler/Charles but for gRPC! The main tool is grpc-dump which transparently inte

Dec 22, 2022
Yet another TCP Port Scanner, but lightning faster.

Fast TCP Port Scanner A highly concurrent TCP port scanner. Run Tests with Code Coverage (Linux) go test -cover Compile (Linux) go build -v -o fglps R

Jul 23, 2022
NUS Downloader but in Go

GoNUSD GoNUSD is a tool which can download Title Metadata (TMD), Tickets and Contents (commonly .app files) from the Nintendo Update Server. Documenta

Apr 13, 2022
WebDAV server for SSH. Similar to sshfs but does not require proprietary MacFUSE on macOS

sshwebdav: WebDAV server for SSH sshwebdav provides a WebDAV server for a remote SSH host. sshwebdav is similar to sshfs but does not require propriet

Nov 9, 2022
GBPool-- a simple but useful golang free proxy pool

GBPool-- a simple but useful golang free proxy pool Intro(English) (中文) GBPool, golang baipiao proxy pool, a free & simple golang proxy pool module, g

May 30, 2022
A quick and dirty but useful tool to download each text/html page from the wayback machine for a specific domain and search for keywords within the saved content

wayback-keyword-search A quick and dirty but useful tool to download each text/html page from the wayback machine for a specific domain and search for

Dec 2, 2022
Snugger is a light weight but fast network recon scanner that is written from pure golang
Snugger is a light weight but fast network recon scanner that is written from pure golang

Snugger is a light weight but fast network recon scanner that is written from pure golang. with this scann you can ARP your network, port scan hosts and host lists, as well as scan for BSSId

May 19, 2022
Gbio - Extremely minimalist RPC framework - Go but interface only

gbio !!! ?? WIP ?? !!! Go but interface only. gbio is a(n): Extremely minimalist

Jan 3, 2022