Hola, tenemos la respuesta a lo que buscabas, deslízate y la obtendrás a continuación.
Ejemplo 1: crear mapa golang
//map in go is a built in type implementaiton of has table//create a empty map
myMap :=make(map[string]string)//insert key-value pair in map
myMap["key"]="value"//read from map
value, ok := myMap["key"]//delete from mapdelete(myMap,"key")
Ejemplo 2: inicializar mapa en golang
// By default maps in Go behaves like a default dictionary in python
m :=make(map[string]int)
m["Dio"]=3
m["Jonathan"]=1
Ejemplo 3: ir a agregar al mapa
m :=make(map[string]int)
m["numberOne"]=1
m["numberTwo"]=2
Ejemplo 4: mapa de golang
package main
import("fmt")type User struct
Name string
Age intfuncmain()var person =map[string]string"name":"john doe","age":"23",var profile =make(map[string]string)
profile["name"]="jane doe"
profile["age"]="23"var user =make(map[string]interface)
user["name"]="peter parker"
user["age"]=30var users =[]map[string]interface"name":"monkey d lufy","age":19,"name":"trafagar d law","age":23,"name":"nico robin","age":20,var userStruct =map[string]User"name":Name:"Monkey D Lufy","age":Age:19,
fmt.Println(person)
fmt.Println(profile)
fmt.Println(user)
fmt.Println(users)
fmt.Println(userStruct)
Ejemplo 5: ¿cuál es el uso de map en golang?
Search Results
Featured snippet from the web
In Go language, a map is a powerful, ingenious, and a versatile data structure. Golang Maps is a collection of unordered pairs of key-value. It is widely used because it provides fast lookups and values that can retrieve, update or delete with the help of keys. It is a reference to a hash table.
Sección de Reseñas y Valoraciones
Agradecemos que desees añadir valor a nuestra información cooperando tu experiencia en los informes.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)