How to get a value from map

后端 未结 2 791
闹比i
闹比i 2020-12-24 06:06

Problem

Fetching data from map

Data Format

res = map[Event_dtmReleaseDate:2009-09-15 00:00:00 +0000 +00:00 Trans_strGuestList: st         


        
2条回答
  •  执念已碎
    2020-12-24 06:40

    In general to get value from map you have to do something like this:

    package main
    
    import "fmt"
    
    func main() {
        m := map[string]string{"foo": "bar"}
        value, exists := m["foo"]
        // In case when key is not present in map variable exists will be false.
        fmt.Printf("key exists in map: %t, value: %v \n", exists, value)
    }
    

    Result will be:

    key exists in map: true, value: bar
    

提交回复
热议问题