I have a simple program that will generate random string and numbers and put it in specific format:
output: A=SKEK673KJK B=67235 C=PDCNE39JSWL
I have 4 func including main:
func genRandInt() string {
//return string(randInt)
}
func genRandStr() string {
//return (randStr)
}
func genFakeData() string {
fmt.Println("A=" + genRanStr() + genRandInt().....etc)
}
func main() {
genFackeData()
}
so far the program working fine, and I am executing it via bash loop in order to run it many time in order to generate huge traffic on the server, but I couldn't reach the generated data as I was expected, what I need to run genFackeData()
in many worker (e.g 50 worker) how I can achieve that in GO ?
(by the way this is very simple version of my program, to not make complicated I have written the simple sample of what I need)
If i am understood your wish right then try to play here https://play.golang.org/p/q_r8PATh6_U
package main
import (
"fmt"
"sync"
)
func genFakeData(wg *sync.WaitGroup, i int) {
fmt.Println("A =",i + 1)
wg.Done()
}
func main() {
var wg sync.WaitGroup
for i:=0 ; i<50 ; i++ {
wg.Add(1)
go genFakeData(&wg, i)
}
wg.Wait()
}