Syntax
Go Check a Map Key Syntax
In Go, check a map key: checks whether a key exists — v, ok := ages["Bob"]
Quick Answer
- Syntax
v, ok := ages["Bob"]
GoSyntax
Check a Map Key
Code example
v, ok := ages["Bob"]
Checks whether a key exists.
How to check a map key in Go
- Open your Go file or editor.
- Copy the example, then replace its sample names and values for your code.
Go Check a Map Key Syntax
Use v, ok := ages["Bob"].
Related Syntax References
Frequently asked questions
What is the Go syntax for check a map key?
Use this pattern: v, ok := ages["Bob"]
Can I copy this Go code example?
Yes. Use Copy code and adapt the example to your program.
Is this Go syntax different on Mac or Windows?
No. The language syntax is the same across operating systems.
Official source · How we verify