Created
May 26, 2013 19:23
-
-
Save AlexMocioi/5653749 to your computer and use it in GitHub Desktop.
Generator numar unic crescator
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 idGenerator() chan int { | |
ids := make(chan int) | |
go func() { | |
id := 0 //intializare cu ultimul nr din baza de date | |
for { | |
id++ | |
ch <- id | |
} | |
}() | |
return ids | |
} | |
ids := idGenerator() | |
id1 := <-ids | |
id2 := <-ids |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment