mirror of
				https://github.com/SourceFellows/gobuch.git
				synced 2025-11-04 07:36:19 +01:00 
			
		
		
		
	initial import
This commit is contained in:
		
							
								
								
									
										25
									
								
								concurrency/channel-range/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								concurrency/channel-range/main.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"math/rand"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var c chan string
 | 
			
		||||
 | 
			
		||||
func printOut() {
 | 
			
		||||
	for i := 1; i < 10; i++ {
 | 
			
		||||
		c <- fmt.Sprintf("Print %v", i)
 | 
			
		||||
		time.Sleep(time.Duration(rand.Intn(500)) * time.Millisecond)
 | 
			
		||||
	}
 | 
			
		||||
	close(c)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
	c = make(chan string)
 | 
			
		||||
	go printOut()
 | 
			
		||||
	for t := range c {
 | 
			
		||||
		fmt.Println(t)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user