package slice // All returns a list of all substrings of s with length n. func All(n int, s string) []string { var ret []string for i, j := 0, n; j <= len(s); i, j = i+1, j+1 { ret = append(ret, s[i:j]) } return ret } // UnsafeFirst returns the first substring of s with length n. func UnsafeFirst(n int, s string) string { if len(s) >= n { return s[:n] } return "" } func First(n int, s string) (string, bool) { if len(s) >= n { return s[:n], true } return "", false }