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.7k Fix yum-complete-transaction error
+19.2k Golang : Check if directory exist and create if does not exist
+12.9k Golang : Convert IPv4 address to packed 32-bit binary format
+10.3k Golang : Wait and sync.WaitGroup example
+9.3k Golang : Generate random Chinese, Japanese, Korean and other runes
+13.9k Golang : How to check if a file is hidden?
+17.9k Golang : Login and logout a user after password verification and redirect example
+7k Golang : constant 20013 overflows byte error message
+9.4k Golang : Qt Yes No and Quit message box example
+7.4k Golang : Convert source code to assembly language
+5k Golang : Constant and variable names in native language
+9.5k Golang : Get all countries currencies code in JSON format