MCPcopy Create free account
hub / github.com/Soypete/Production-Go-Examples / detectWords

Function detectWords

exercise-1/solution/main.go:19–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17}
18
19func detectWords() int {
20 msgs := getWords()
21 var numWordsDetected int
22 for _, word := range msgs {
23 // this condition returns words like whale, whaling, whales
24 if strings.Contains(word, "whal") {
25 numWordsDetected++
26 // golang is too powerful, so we have to slow it down to run pprof
27 time.Sleep(50 * time.Millisecond)
28 }
29 }
30 return numWordsDetected
31
32}
33
34func main() {
35 // run pprof

Callers 1

mainFunction · 0.70

Calls 1

getWordsFunction · 0.70

Tested by

no test coverage detected