Last active
October 26, 2017 06:12
-
-
Save brailateo/6018021 to your computer and use it in GitHub Desktop.
Generator automat de numere seriale în Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func jobIdGenerator(init int) chan int { | |
ids := make(chan int) | |
go func() { | |
id := init //intializare cu ultimul nr din baza de date | |
for { | |
id++ | |
ids <- id | |
} | |
}() | |
return ids | |
} | |
... | |
var jobExecSerialNumberGenerator chan int | |
jobExecSerialNumberGenerator = jobIdGenerator(startValue) | |
... | |
idJob := <- jobExecSerialNumberGenerator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment