Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Replace instances of the string "master" with "main" in a git binary executable
package main
import (
func main() {
byt, err := ioutil.ReadFile(os.Args[1])
if err != nil {
re := regexp.MustCompile("master([^\x00]*)")
out := re.ReplaceAll(byt, []byte("main${1}\x00\x00"))
io.Copy(os.Stdout, bytes.NewBuffer(out))

This comment has been minimized.

Copy link
Owner Author

ear7h commented Jun 25, 2020

Run with:

go run git-decolonize.go $(which git) > git-decolonized
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.