Golang builtin.close() function example
package builtin
The close built-in function closes a channel, which must be either bidirectional or send-only. It should be executed only by the sender, never the receiver, and has the effect of shutting down the channel after the last sent value is received.
Golang builtin.close() function usage example
jobs := make(chan Job)
go func() {
for _, job := range jobList {
jobs <- job // Blocks waiting for a receive
}
close(jobs) // close the channel
}()
Reference :
Advertisement
Something interesting
Tutorials
+24.6k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?
+43.3k Golang : Convert []byte to image
+9.4k Golang : Apply Histogram Equalization to color images
+34.6k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+32.2k Golang : Convert []string to []byte examples
+25.6k Golang : convert rune to integer value
+6.9k Golang : Fibonacci number generator examples
+14k Golang : Google Drive API upload and rename example
+29.5k Golang : Login(Authenticate) with Facebook example
+44.9k Golang : Use wildcard patterns with filepath.Glob() example
+6.3k Golang : How to get capacity of a slice or array?
+18.7k Unmarshal/Load CSV record into struct in Go