Created
January 30, 2020 03:03
-
-
Save rafaelbeckel/63d4f372d6006cc0b92824443cae752b to your computer and use it in GitHub Desktop.
Create new Golang project and Github repository with one single command
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
# put that in your .bash_profile | |
function ng() { | |
mkdir $GOPATH/src/github.com/rafaelbeckel/$1 && | |
cd $GOPATH/src/github.com/rafaelbeckel/$1 && | |
git init && | |
curl -u 'rafaelbeckel' https://api.github.com/user/repos -d "{\"name\":\"$1\", \"private\":true, \"gitignore_template\": \"Go\" }" && | |
git remote add origin https://github.com/rafaelbeckel/$1 | |
&& git pull origin master | |
&& touch main.go | |
&& code .; | |
} | |
# Usage: ng YOUR_REPO_NAME | |
# @TODO needs some cleanup, but it works as-is for me. | |
# Feel free to replace my name and "code" to your favorite editor | |
# @TODO start with a skeleton or a hello world instead of an empty file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was annoyed that every time I started a new project in Go, I needed to manually create a new repository and the right path structure in my filesystem to match it.
So, I have created a command for it. It creates the repo in Github, clones it to the correct path in my filesystem, includes a Go
.gitignore
template, creates a main.go file, and fires up my favorite editor with the project opened up.