Documentation ¶
Index ¶
- Variables
- func DownloadFile(filepath string, url string) error
- func DownloadURL(url string) ([]byte, error)
- func ExtractOwnerRepoFromGitURL(url string) (owner string, repo string, err error)
- func Filter(arr interface{}, cond func(interface{}) bool) interface{}
- func GitDir() (string, error)
- func GitRemoteOriginURL() (string, error)
- func IfThenElse(condition bool, a interface{}, b interface{}) interface{}
- func IsCygwinTerminal(f *os.File) bool
- func IsGitRepo() bool
- func NestedMapLookup(m map[string]interface{}, ks ...string) (rval interface{}, err error)
- func OpenInBrowser(url string) error
- func RandomString(length int) (string, error)
- func StringInArray(str string, list []string) bool
- func SumFloat64(array []float64) float64
- func SumInt(array []int) int
- func ToplevelDir() (string, error)
- func TruncateString(s string, num int) string
- type GitRemoteURL
Constants ¶
This section is empty.
Variables ¶
var GitCommand = func(args ...string) (*exec.Cmd, error) { gitExe, err := safeexec.LookPath("git") if err != nil { programName := "git" if runtime.GOOS == "windows" { programName = "Git for Windows" } return nil, fmt.Errorf("unable to find git executable in PATH; please install %s before retrying", programName) } return exec.Command(gitExe, args...), nil }
var IsTerminal = func(f *os.File) bool { return isatty.IsTerminal(f.Fd()) || IsCygwinTerminal(f) }
Functions ¶
func DownloadFile ¶
DownloadFile will download a url to a local file. It's efficient because it will write as it downloads and not load the whole file into memory.
func DownloadURL ¶ added in v0.6.0
DownloadURL downloads from a given URL and returns the response body
func ExtractOwnerRepoFromGitURL ¶ added in v0.4.0
ExtractOwnerRepoFromGitURL extracts owner and repo from a Git URL: https or ssh url
func GitRemoteOriginURL ¶ added in v0.4.0
func IfThenElse ¶
func IfThenElse(condition bool, a interface{}, b interface{}) interface{}
IfThenElse evaluates a condition, if true returns the first parameter otherwise the second
func IsCygwinTerminal ¶ added in v0.4.0
func IsGitRepo ¶ added in v0.4.0
func IsGitRepo() bool
IsGitRepo indicates whether the current working directory is a git repository
func NestedMapLookup ¶
NestedMapLookup ... m: a map from strings to other maps or values, of arbitrary depth ks: successive keys to reach an internal or leaf node (variadic) If an internal node is reached, will return the internal map
Returns: (Exactly one of these will be nil) rval: the target node (if found) err: an error created by fmt.Errorf
https://gist.github.com/ChristopherThorpe/fd3720efe2ba83c929bf4105719ee967 Licensed under the CC by 4.0 https://creativecommons.org/licenses/by/4.0/
func OpenInBrowser ¶ added in v0.3.0
OpenInBrowser opens the url in a web browser based on OS
func RandomString ¶ added in v0.3.0
RandomString generates a random string of a given length
func StringInArray ¶
StringInArray indicates whether a string value is contained in an array or slice
func SumFloat64 ¶ added in v0.11.0
SumFloat64 returns the sum of all float64 values of the slice
func ToplevelDir ¶ added in v0.4.0
ToplevelDir returns the top-level directory path of the current repository
func TruncateString ¶ added in v0.6.0
TruncateString truncates the given string to the num provided and adds an ellipsis (...).
Types ¶
type GitRemoteURL ¶ added in v0.4.0
type GitRemoteURL struct { Proto string // https , ssh , git User string // optional Host string // host or host:port Path string // full path to the repo (without .git ext) // contains filtered or unexported fields }
func ParseGitRemoteOriginURL ¶ added in v0.4.0
func ParseGitRemoteOriginURL(url string) (*GitRemoteURL, error)
ParseGitRemoteOriginURL parses a git remote origin url into a struct that can be uniquely identified regardless the used protocol
func (*GitRemoteURL) Hash ¶ added in v0.4.0
func (grURL *GitRemoteURL) Hash() string
Hash computes the hash for a git remote URL only on non changing fields: different protocol or user can still refer to the same remote origin
func (*GitRemoteURL) String ¶ added in v0.4.0
func (grURL *GitRemoteURL) String() string
String returns the original raw URL of the git remote