summaryrefslogtreecommitdiff
path: root/go/acronym/acronym.go
blob: 2752fd12065564e03d3e33b336ea28822fc098f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package acronym

import (
	"bytes"
	"strings"
	"unicode"
)

const testVersion = 1

func abbreviate(s string) string {
	buf := new(bytes.Buffer)
	for i, v := range strings.Title(s) {
		if i > 0 && unicode.IsUpper(rune(s[i-1])) {
			continue
		}
		if unicode.IsUpper(v) {
			buf.WriteRune(v)
		}

	}
	return buf.String()
}