Golang builtin.make() function example
package builtin
The make built-in function allocates and initializes an object of type slice, map, or chan (only). Like new, the first argument is a type, not a value. Unlike new, make's return type is the same as the type of its argument, not a pointer to it.
Golang builtin.make() function usage example
package main
import "fmt"
type Person struct {
Age int
}
var personmap map[string]Person
func main() {
personmap = make(map[string]Person) // initializes the person object
personmap["Adam"] = Person{36}
fmt.Println("Before delete : ", personmap)
delete(personmap, "Adam")
fmt.Println("After delete : ", personmap)
}
Advertisement
Something interesting
Tutorials
+11.1k Golang : Web routing/multiplex example
+13.7k Golang : Activate web camera and broadcast out base64 encoded images
+12.6k Golang : Drop cookie to visitor's browser and http.SetCookie() example
+5.6k Golang : Frobnicate or tweaking a string example
+17.9k Golang : Simple client server example
+6.3k Javascript : Generate random key with specific length
+15.4k Golang : invalid character ',' looking for beginning of value
+21.8k Golang : Upload big file (larger than 100MB) to AWS S3 with multipart upload
+6.7k Golang : Reverse by word
+23.6k Golang : minus time with Time.Add() or Time.AddDate() functions to calculate past date
+8.2k Prevent Write failed: Broken pipe problem during ssh session with screen command
+5.3k Python : Convert(cast) string to bytes example