Tokens returns a token generation function with takes a series of tokens and output them in order.
(tokens ...string)
| 4 | |
| 5 | // Tokens returns a token generation function with takes a series of tokens and output them in order. |
| 6 | func Tokens(tokens ...string) func() string { |
| 7 | var i int |
| 8 | lock := sync.Mutex{} |
| 9 | return func() string { |
| 10 | lock.Lock() |
| 11 | defer lock.Unlock() |
| 12 | res := tokens[i%len(tokens)] |
| 13 | i++ |
| 14 | return res |
| 15 | } |
| 16 | } |
no outgoing calls
searching dependent graphs…