mirror of
				https://github.com/SourceFellows/gobuch.git
				synced 2025-11-04 07:36:19 +01:00 
			
		
		
		
	initial import
This commit is contained in:
		
							
								
								
									
										33
									
								
								microservices/go-channel/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								microservices/go-channel/main.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"math/rand"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
 | 
			
		||||
	tc := make(chan time.Time)
 | 
			
		||||
 | 
			
		||||
	var c int64 = 0
 | 
			
		||||
 | 
			
		||||
	go func() {
 | 
			
		||||
		for {
 | 
			
		||||
			go func() {
 | 
			
		||||
				for {
 | 
			
		||||
					c++
 | 
			
		||||
					i := rand.Int31n(10)
 | 
			
		||||
					time.Sleep(time.Duration(i) * time.Millisecond)
 | 
			
		||||
					tc <- time.Now()
 | 
			
		||||
				}
 | 
			
		||||
			}()
 | 
			
		||||
		}
 | 
			
		||||
	}()
 | 
			
		||||
 | 
			
		||||
	for t := range tc {
 | 
			
		||||
		fmt.Println(t)
 | 
			
		||||
		fmt.Println(c)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user