Skip to content

Instantly share code, notes, and snippets.

@ahmdrz
Created September 8, 2016 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmdrz/67eb5e017097123b405d0c04876c6d75 to your computer and use it in GitHub Desktop.
Save ahmdrz/67eb5e017097123b405d0c04876c6d75 to your computer and use it in GitHub Desktop.
// 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