-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathlorem_text.go
53 lines (44 loc) · 1.31 KB
/
lorem_text.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
44
45
46
47
48
49
50
51
52
53
package kolpa
import (
"strconv"
"strings"
)
// LoremWord function returns a random lorem word.
// A convenience function, same as g.GenericGenerator("lorem_word").
// Sample Output: dolores
func (g *Generator) LoremWord() string {
return g.GenericGenerator("lorem_word")
}
// LoremSentence function returns a random lorem sentence.
// Sample Output: Provident nobis nostrum blanditiis voluptatem animi rerum harum.
func (g *Generator) LoremSentence() string {
var sLen int
var sentence string
sentenceLen := g.numericRandomizer([]string{"1", "2", "15"})
sLen, err := strconv.Atoi(sentenceLen)
if err == nil {
for i := 0; i < sLen; i++ {
if len(sentence) == 0 {
sentence = strings.Title(g.LoremWord())
}
sentence += " " + g.LoremWord()
}
sentence += "."
}
return sentence
}
// LoremParagraph function returns a random lorem paragraph.
// Sample Output: Quia et minima saepe aspernatur laboriosam non id eum. Nulla iste ea
// necessitatibus molestiae omnis et est. Nisi cum commodi ex rerum aperiam earum in.
func (g *Generator) LoremParagraph() string {
var pLen int
var paragraph string
paragraphLen := g.numericRandomizer([]string{"1", "2", "10"})
pLen, err := strconv.Atoi(paragraphLen)
if err == nil {
for i := 0; i < pLen; i++ {
paragraph += g.LoremSentence() + " "
}
}
return paragraph
}