Ubuntu Pastebin

Paste from axw at Wed, 25 Feb 2015 02:46:53 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
func split(str string) (string, int) {
        i := strings.LastIndexFunc(str, func(r rune) bool {
                return !unicode.IsDigit(r)
        }) + 1
        if i == len(str) {
                return str, -1
        }
        n, err := strconv.Atoi(str[i:])
        if err != nil {
                panic(err)
        }
        return str[:i], n
}
Download as text