Golang reflect.MakeChan() function example
package reflect
Golang reflect.MakeChan() function usage example.
package main
import (
"fmt"
"reflect"
)
func main() {
var str chan string // channel string type
var strValue reflect.Value = reflect.ValueOf(&str)
indirectStr := reflect.Indirect(strValue)
//fmt.Println("str type : ", indirectStr.Kind())
// create new channel
value := reflect.MakeChan(indirectStr.Type(), 1024)
fmt.Printf("Value type is [%v] and capacity [%v] bytes.", value.Kind(), value.Cap())
}
Reference :
Advertisement
Something interesting
Tutorials
+11.6k Get form post value in Go
+14.4k Golang : Parsing or breaking down URL
+7.2k CloudFlare : Another way to get visitor's real IP address
+33k Golang : How to check if a date is within certain range?
+5.7k Golang : Struct field tags and what is their purpose?
+12.8k Golang : Listen and Serve on sub domain example
+18.5k Golang : Example for RSA package functions
+8.3k Golang : Implementing class(object-oriented programming style)
+8.1k Golang : Variadic function arguments sanity check example
+6k Golang : Experimenting with the Rejang script
+27.9k Golang : Decode/unmarshal unknown JSON data type with map[string]interface
+25.2k Golang : Storing cookies in http.CookieJar example