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
+11k Golang : Replace a parameter's value inside a configuration file example
+44.9k Golang : Use wildcard patterns with filepath.Glob() example
+7k Web : How to see your website from different countries?
+31.1k Golang : Calculate percentage change of two values
+15.9k Golang : Get current time from the Internet time server(ntp) example
+18.6k Golang : Generate thumbnails from images
+12.4k Golang : Encrypt and decrypt data with x509 crypto
+22.1k Golang : Join arrays or slices example
+7k Golang : How to call function inside template with template.FuncMap
+21.5k Golang : How to read float value from standard input ?
+5.4k Golang : Get S3 or CloudFront object or file information
+26.1k Mac/Linux and Golang : Fix bind: address already in use error