func expand(s, defaultPrefix string) string {
	if strings.Contains(s, ":") {
		return s
	}
	parts := strings.SplitN(s, "/", 2)
	if len(parts) < 2 {
		return s
	}
	return defaultPrefix + parts[0] + "/" + parts[1] + ".git"
}
expand completes the implicitly relative clone URL s of form "project/repo" into
absolute clone URL.

If s does not have the required form, it is returned unchanged.
unmodified.
package main
import (
	"fmt"
	"log"
	"os"
	"os/exec"
	"path/filepath"
	"strings"
	"github.com/mitchellh/go-homedir"
)
const (
	defaultTargetPath = "~/src"
	defaultPrefix = "git@github.com:"
)
const usage = `
Usage: git-get (URL|PROJECT/REPOSITORY)
  $ git get joneskoo/git-get                    # PROJECT/REPOSITORY
  $ git get git@github.com:joneskoo/git-get     # URL
Regardless of working directory where git get is executed, this expands to:
  $ git clone git@github.com:joneskoo/git-get ~/src/github.com/joneskoo/git-get
This allows easy cloning of repositories into an uniform directory structure.
`
func main() {
	logger := log.New(os.Stderr, "git-get: ", 0)
	if len(os.Args) != 2 {
		logger.Fatalln(usage)
	}
	relativeCloneURL := os.Args[1]
	targetPath := defaultTargetPath
	if s := os.Getenv("GIT_GET_ROOT"); s != "" {
		targetPath = s
	}
	var err error
	targetPath, err = homedir.Expand(targetPath)
	if err != nil {
		logger.Fatalf("failed to expand target path: %v", err)
	}
	prefix := defaultPrefix
	if s := os.Getenv("GIT_GET_PREFIX"); s != "" {
		prefix = s
	}
	cloneURL := expand(relativeCloneURL, prefix)
	td, err := targetDir(cloneURL)
	if err != nil {
		logger.Fatal(err)
	}
	cmd := exec.Command("git", "clone", cloneURL, filepath.Join(targetPath, td))
	cmd.Stdin = os.Stdin
	cmd.Stderr = os.Stderr
	cmd.Stdout = os.Stdout
	err = cmd.Run()
	if ee, ok := err.(*exec.ExitError); ok {
		os.Exit(ee.ExitCode())
	}
	if err != nil {
		logger.Fatalf("calling git failed: %v", err)
	}
}