多值函数和if语句[重复]

This question already has an answer here:

This tests if a map contains a certain value:

_, ok := myMap["foo"]

Is there a way to use this check in an if statement, so that I can chain multiple tests together?

if ("foo" in map1) || ("bar" in map2) {
// do stuff
}
</div>

This should be roughly what you're looking for.

if _, ok := myMap["foo"]; ok {
    //do stuff
}

You should be able to chain multiple statements in the parentheses so that you can have multiple checks at a time.

if (_, okfoo := myMap["foo"]; _, okbar := myMap["bar"]; okfoo || okbar) {
    // do stuff
}