All Projects → rogpeppe → Gohack

rogpeppe / Gohack

Licence: bsd-3-clause
Make temporary edits to your Go module dependencies

Programming Languages

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

Labels

Projects that are alternatives of or similar to Gohack

Framer Modules
Discover, install and save your favorite modules at one place
Stars: ✭ 338 (-54.26%)
Mutual labels:  modules
Automate Everything
这是我准备写的第一本书,其实早些时候已经打算开始写书了,只是苦于没有写书经验,无从下手。写书不同于博客,写书需要将知识,经验等系统化地讲述出来,而我现在恰巧缺乏这种表现能力。因此我决定在这里将项目中零散的东西记录下来,然后后期润色一下,写成一本书。
Stars: ✭ 430 (-41.81%)
Mutual labels:  modules
Typescript Plugin Css Modules
A TypeScript language service plugin providing support for CSS Modules.
Stars: ✭ 520 (-29.63%)
Mutual labels:  modules
Nod
Node.js module generator/boilerplate with Babel, Jest, Flow, Documentation and more
Stars: ✭ 355 (-51.96%)
Mutual labels:  modules
Box
Write reusable, composable and modular R code
Stars: ✭ 388 (-47.5%)
Mutual labels:  modules
Pygorithm
A Python module for learning all major algorithms
Stars: ✭ 4,256 (+475.91%)
Mutual labels:  modules
Modclean
Remove unwanted files and directories from your node_modules folder
Stars: ✭ 309 (-58.19%)
Mutual labels:  modules
Date Fns
⏳ Modern JavaScript date utility library ⌛️
Stars: ✭ 27,650 (+3641.54%)
Mutual labels:  modules
Mastering Modular Javascript
📦 Module thinking, principles, design patterns and best practices.
Stars: ✭ 3,972 (+437.48%)
Mutual labels:  modules
Bower Material
This repository is used for publishing the AngularJS Material v1.x library
Stars: ✭ 510 (-30.99%)
Mutual labels:  modules
Repl
The Learning Hub for UoL's Online CS Students
Stars: ✭ 367 (-50.34%)
Mutual labels:  modules
Detective
Find all calls to require() no matter how deeply nested using a proper walk of the AST
Stars: ✭ 387 (-47.63%)
Mutual labels:  modules
Es Check
Checks the version of ES in JavaScript files with simple shell commands 🏆
Stars: ✭ 448 (-39.38%)
Mutual labels:  modules
Moditect
Tooling for the Java Module System
Stars: ✭ 337 (-54.4%)
Mutual labels:  modules
Resolve
Implements the node.js require.resolve() algorithm
Stars: ✭ 622 (-15.83%)
Mutual labels:  modules
A To Z List Of Useful Node.js Modules
Collection of most awesome node modules that will extend the capability of your node.js application.
Stars: ✭ 315 (-57.37%)
Mutual labels:  modules
Trex
Package Manager for deno 🦕
Stars: ✭ 433 (-41.41%)
Mutual labels:  modules
Piral
Framework for next generation web apps using microfrontends. 🚀
Stars: ✭ 711 (-3.79%)
Mutual labels:  modules
Github Actions Golang
GitHub Actions as CI for Go
Stars: ✭ 672 (-9.07%)
Mutual labels:  modules
Cms
Decoupled CMS for any Laravel app, gain control of: pages, blogs, galleries, events, images, custom modules and more.
Stars: ✭ 498 (-32.61%)
Mutual labels:  modules

Gohack: mutable checkouts of Go module dependencies

The new Go module system is awesome. It ensures repeatable, deterministic builds of Go code. External module code is cached locally in a read-only directory, which is great for reproducibility. But if you're used to the global mutable namespace that is $GOPATH, there's an obvious question: what if I'm hacking on my program and I want to change one of those external modules?

You might want to put a sneaky log.Printf statement to find out how some internal data structure works, or perhaps try out a bug fix to see if it solves your latest problem. But since all those external modules are in read-only directories, it's hard to change them. And you really don't want to change them anyway, because that will break the integrity checking that the Go tool does when building.

Luckily the modules system provides a way around this: you can add a replace statement to the go.mod file which substitutes the contents of a directory holding a module for the readonly cached copy. You can of course do this manually, but gohack aims to make this process pain-free.

Install gohack with

go get github.com/rogpeppe/gohack

or use gobin:

gobin github.com/rogpeppe/gohack

For quick edits to a module (without version control information)

If the module to edit is example.com/foo/bar, run:

gohack get example.com/foo/bar

This will make a copy of the module into $HOME/gohack/example.com/foo/bar and add replace directives to the local go.mod file:

replace example.com/foo/bar => /home/rog/gohack/example.com/foo/bar

Note: This copy will not include version control system information so it is best for quick edits that aren't intended to land back into version control.

To edit the module with full version control

Run:

gohack get -vcs example.com/foo/bar

This will clone the module's repository to $HOME/gohack/example.com/foo/bar, check out the correct version of the source code there and add the replace directive into the local go.mod file.

Undoing replacements

Once you are done hacking and wish to revert to the immutable version, you can remove the replace statement with:

gohack undo example.com/foo/bar

or you can remove all gohack replace statements with:

gohack undo

Note that undoing a replace does not remove the external module's directory - that stays around so your changes are not lost. For example, you might wish to turn that bug fix into an upstream PR.

If you run gohack on a module that already has a directory, gohack will try to check out the current version without recreating the repository, but only if the directory is clean - it won't overwrite your changes until you've committed or undone them.

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].