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
+5.6k PHP : Convert CSV to JSON with YQL example
+5.4k Golang : Qt update UI elements with core.QCoreApplication_ProcessEvents
+9k Golang : Inject/embed Javascript before sending out to browser example
+11.6k Swift : Convert (cast) Float to String
+25.7k Golang : How to write CSV data to file
+7.9k Golang : Get today's weekday name and calculate target day distance example
+11.5k CodeIgniter : Import Linkedin data
+15.6k Chrome : ERR_INSECURE_RESPONSE and allow Chrome browser to load insecure content
+10.5k Generate Random number with math/rand in Go
+5.7k Unix/Linux/MacOSx : Get local IP address
+25k Golang : Create PDF file from HTML file
+24k Golang : Find biggest/largest number in array