scripts.go
func Init() error {
	// prevent concurrent call
	initMutex.Lock()
	defer initMutex.Unlock()

	// if validation has been done before and binary located in
	// PATH, return.
	if gitBinary != "" {
		return nil
	}

	// locate git binary in path
	var err error
	if gitBinary, err = gos.LookPath("git"); err != nil {
		return fmt.Errorf("git middleware requires git installed. Cannot find git binary in PATH")
	}

	// locate bash in PATH. If not found, fallback to sh.
	// If neither is found, return error.
	shell = "bash"
	if _, err = gos.LookPath("bash"); err != nil {
		shell = "sh"
		if _, err = gos.LookPath("sh"); err != nil {
			return fmt.Errorf("git middleware requires either bash or sh")
		}
	}
	return nil
}
func Init() error {
	// prevent concurrent call
	initMutex.Lock()
	defer initMutex.Unlock()

	// if validation has been done before and binary located in
	// PATH, return.
	if gitBinary != "" {
		return nil
	}

	// locate git binary in path
	var err error
	if gitBinary, err = gos.LookPath("git"); err != nil {
		return fmt.Errorf("git middleware requires git installed. Cannot find git binary in PATH")
	}

	// locate bash in PATH. If not found, fallback to sh.
	// If neither is found, return error.
	shell = "bash"
	if _, err = gos.LookPath("bash"); err != nil {
		shell = "sh"
		if _, err = gos.LookPath("sh"); err != nil {
			return fmt.Errorf("git middleware requires either bash or sh")
		}
	}
	return nil
}
func Init ( ) error { // prevent concurrent call initMutex . Lock ( ) defer initMutex . Unlock ( ) // if validation has been done before and binary located in // PATH, return. if gitBinary != " " { return nil } // locate git binary in path var err error if gitBinary , err = gos . LookPath ( " " ) ; err != nil { return fmt . Errorf ( " " ) } // locate bash in PATH. If not found, fallback to sh. // If neither is found, return error. shell = " " if _ , err = gos . LookPath ( " " ) ; err != nil { shell = " " if _ , err = gos . LookPath ( " " ) ; err != nil { return fmt . Errorf ( " " ) } } return nil }
// Init validates git installation, locates the git executable
// binary in PATH and check for available shell to use.
Init validates git installation locates the git executable binary in PATH and check for available shell to use .