Created
September 8, 2016 07:39
-
-
Save ahmdrz/67eb5e017097123b405d0c04876c6d75 to your computer and use it in GitHub Desktop.
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
// test project main.go | |
package main | |
import ( | |
"crypto/sha1" | |
"fmt" | |
"time" | |
) | |
func main() { | |
id := make(chan string) | |
go func() { | |
h := sha1.New() | |
c := []byte(time.Now().String()) | |
for { | |
h.Write(c) | |
id <- fmt.Sprintf("%x", h.Sum(nil)) | |
} | |
}() | |
fmt.Printf("This program will get 10 IDs from the id channel, print them and terminate\n\n") | |
for i := 0; i < 10; i++ { | |
fmt.Printf("%s\n", <-id) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment