如题,方法如下:

if val, ok := dict["foo"]; ok {
    //do something here
}