func LoadSpecificationSetFromGithub(
	token string,
	repoURL string,
	refName string,
	internalPath string,
	nameConvertFunc AttributeNameConverterFunc,
	typeConvertFunc AttributeTypeConverterFunc,
	typeMappingName string,
) (SpecificationSet, error) {
	var auth transport.AuthMethod
	if token != "" {
		auth = &http.BasicAuth{
			Username: "Bearer",
			Password: token,
		}
	}
	tmpFolder, err := ioutil.TempDir("", "regolithe-refs-head")
	if err != nil {
		return nil, err
	}
	defer func(f string) { _ = os.RemoveAll(f) }(tmpFolder)  
	var (
		ref           plumbing.ReferenceName
		needsCheckout bool
	)
	givenHash := plumbing.NewHash(refName)
	if !givenHash.IsZero() {
		ref = plumbing.NewReferenceFromStrings("refs/heads/master", "").Name()
		needsCheckout = true
	} else {
		ref = plumbing.NewReferenceFromStrings("refs/heads/"+refName, "").Name()
	}
	log.Printf("Retrieving repository: ref=%s repo=%s path=%s", refName, repoURL, internalPath)
	cloneFunc := func(folder string, ref plumbing.ReferenceName) (*git.Repository, error) {
		return git.PlainClone(
			folder,
			false,
			&git.CloneOptions{
				URL:           repoURL,
				Progress:      nil,
				ReferenceName: ref,
				Auth:          auth,
			})
	}
	repo, err := cloneFunc(tmpFolder, ref)
	if err != nil {
		if err == plumbing.ErrReferenceNotFound {
			log.Printf("failed to clone with refs/heads: ref=%s repo=%s path=%s err=%s", refName, repoURL, internalPath, err)
			tmpFolder, err = ioutil.TempDir("", "regolithe-refs-tags")
			if err != nil {
				return nil, err
			}
			defer func(f string) { _ = os.RemoveAll(f) }(tmpFolder)  
			ref = plumbing.NewReferenceFromStrings("refs/tags/"+refName, "").Name()
			repo, err = cloneFunc(tmpFolder, ref)
			if err != nil {
				return nil, err
			}
		} else {
			return nil, err
		}
	}
	if needsCheckout {
		wt, e := repo.Worktree()
		if e != nil {
			return nil, e
		}
		if err = wt.Checkout(
			&git.CheckoutOptions{
				Hash: givenHash,
			}); err != nil {
			return nil, err
		}
	}
	set, err := LoadSpecificationSet(
		path.Join(tmpFolder, internalPath),
		nameConvertFunc,
		typeConvertFunc,
		typeMappingName,
	)
	if err != nil {
		return nil, err
	}
	return set, nil
}
LoadSpecificationSetFromGithub loads a set of specs from github.
package spec
import (
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"path"
	"sort"
	"strings"
	git "gopkg.in/src-d/go-git.v4"
	"gopkg.in/src-d/go-git.v4/plumbing"
	"gopkg.in/src-d/go-git.v4/plumbing/transport"
	"gopkg.in/src-d/go-git.v4/plumbing/transport/http"
)
type AttributeNameConverterFunc func(name string) string
type AttributeTypeConverterFunc func(typ AttributeType, subtype string) (converted string, provider string)
type specificationSet struct {
	configuration  *Config
	typeMap        TypeMapping
	validationsMap ValidationMapping
	apiInfo        *APIInfo
	parametersMap  ParameterMapping
	specs map[string]Specification
}