To create a map with a value of type float, you can use the make function in Golang.
main.go35 chars2 lines
Replace keyType
with the type of keys you want to use in your map. The float64
type indicates that the values in the map should be of type float.
Here is an example of creating a map with float values:
main.go236 chars14 lines
In this example, we created a map with string keys and float values. We then added some key-value pairs to the map and printed the map to the console. You can also initialize a map with some values using a map literal like this:
main.go124 chars6 lines
The output will be the same as the previous example: map[apple:2.99 banana:1.5 orange:0.8]
gistlibby LogSnag