package ssh import ( "errors" "regexp" ) var gitCommandRx = regexp.MustCompile(`^(git-upload-pack|git-receive-pack|git-upload-archive) '(.+)'$`) type GitCommand struct { Command string Args string } func parseGitCommand(raw string) (GitCommand, error) { matches := gitCommandRx.FindStringSubmatch(raw) if matches == nil { return GitCommand{}, errors.New("unrecognized command") } return GitCommand{ Command: matches[1], Args: matches[2], }, nil }