-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
root.go
43 lines (33 loc) · 930 Bytes
/
root.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Provides Random Lorem Ipsum, and other utilities.
package lorelai
import (
"math/rand"
"strings"
"time"
)
// Get [quantity] words
func LoremWords(quantity int) string {
rand.Seed(time.Now().UnixNano())
lorem := ""
for i := 0; i < quantity; i++ {
lorem += DATA[rand.Intn(1100)] + " "
}
return lorem
}
// Get [quantity] words, the first word is capitalized, ends with a dot.
func FormattedLoremWords(quantity int) string {
return formatWords(LoremWords(quantity))
}
// Get a single word
func Word() string {
word := LoremWords(1)
return strings.TrimSpace(strings.ToUpper(word[0:1]) + word[1:])
}
// Get a sentence, with the first word capitalized, of eight words that ends with a dot.
func Sentence() string {
return formatWords(LoremWords(8))
}
// Get a paragraph, with the first word capitalized, of forty five words that ends with a dot.
func Paragraph() string {
return formatWords(LoremWords(45))
}