package sim import "strings" // simWords is the word pool the fake output is drawn from. var simWords = []string{ "alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta", "theta", "iota", "kappa", "lambda", "mu", "nu", "xi", "omicron", "pi", } // tokenText returns the text of the n-th generated token (n starts at 1). // It must be deterministic: the text written into the cache on completion has // to match exactly what was streamed to the client. func tokenText(n int) string { return " " + simWords[(n-1)%len(simWords)] } // generatedText returns the concatenation of the first n tokens. func generatedText(n int) string { var b strings.Builder b.Grow(n * 7) for i := 1; i <= n; i++ { b.WriteString(tokenText(i)) } return b.String() }