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
+7.4k Golang : Check to see if *File is a file or directory
+20.2k Golang : Count number of digits from given integer value
+10.6k Golang : ISO8601 Duration Parser example
+17.4k Golang : Multi threading or run two processes or more example
+13.5k Facebook PHP getUser() returns 0
+9.5k Golang : Changing a RGBA image number of channels with OpenCV
+41k Golang : How to check if a string contains another sub-string?
+13.7k Golang : Tutorial on loading GOB and PEM files
+19.9k Golang : How to get time from unix nano example
+7.5k Golang : Shuffle strings array
+29.7k Golang : Record voice(audio) from microphone to .WAV file
+15.6k Golang : ROT47 (Caesar cipher by 47 characters) example