Last active
September 4, 2018 21:53
-
-
Save carlca/e97eccd545f2465f1e2a0c42356e6ffd to your computer and use it in GitHub Desktop.
Attempt to provide a one click way of simulating "go get" in Go 1.11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# At the moment this script still uses $GOPATH even though Go Modules removes the need to use $GOPATH. | |
# I will try to sort this, or anyone else is welcome to change it. Can you alter someone else's gist? | |
# Who knows! | |
# | |
# This script is best run from an alias which can be defined as... | |
# alias gog='. gog.sh' | |
# The use of the leading . ensures that the cd command in line 31 will leave the pwd permanently as $clone_folder, | |
# after the script has finished running. | |
# | |
# If less kicks in on long ls listings, just press q to quit. | |
# | |
clone_full_path=$1 | |
# https://github.com/elves/elvish.git | |
git_path=${clone_full_path:8} | |
# github.com/elves/elvish.git | |
git_path=${git_path%.*} | |
# github.com/elves/elvish | |
full_folder=$GOPATH/src/$git_path | |
# ~/code/go/src/github.com/elves/elvish | |
clone_parent=${full_folder%/*} | |
# ~/code/go/src/github.com/elves | |
clone_folder=${full_folder##*/} | |
# elvish | |
mkdir -p $clone_parent | |
cd $clone_parent | |
# cd ~/code/go/src/github.com/elves | |
git clone $clone_full_path | |
# git clone downloads into ~/code/go/src/github.com/elves/elvish | |
cd $clone_folder | |
# cd ~/code/go/src/github.com/elves/elvish | |
rm -rf go.mod | |
rm -rf go.sub | |
go mod init $git_path | |
# go mod init github.com/elves/elvish | |
ls -l|less |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment