utils.go
1package common
2
3import (
4 "fmt"
5
6 "github.com/muesli/reflow/truncate"
7)
8
9// TruncateString is a convenient wrapper around truncate.TruncateString.
10func TruncateString(s string, max int) string {
11 if max < 0 {
12 max = 0
13 }
14 return truncate.StringWithTail(s, uint(max), "…")
15}
16
17// RepoURL returns the URL of the repository.
18func RepoURL(publicURL, name string) string {
19 return fmt.Sprintf("git clone %s/%s", publicURL, name)
20}