Skip to content

XFerion Latin America S.A.

Software Development

Recent Posts

  • golang: Check if key exists in map
  • Golang: Reverse ISOWeek, get the date of the first day of ISO week
  • Golang: measure time to execute code
  • Golang create directory
  • Golang delete file

Recent Comments

  • Abinhho on Building a Golang web application with Revel
  • stephan on Golang substr or substring equivalent
  • a-h on Golang substr or substring equivalent
  • legends2k on Golang substr or substring equivalent
  • Serhii Herasymov on Golang: Reverse ISOWeek, get the date of the first day of ISO week

Archives

  • July 2015
  • May 2015
  • February 2015
  • January 2015

Categories

  • Go Programming
  • Software Development
  • Web Programming

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Month: July 2015

golang: Check if key exists in map

golang: Check if key exists in map

You can easily check if a key exists in a go map by using the ok result:


value, ok := myMap[key]

Or in an one line check:


if val, ok := myMap[key]; ok {
// do something
}

 

 

Posted on July 30, 2015Categories Go ProgrammingTags go, go code, Golang, kb, map, programmingLeave a comment on golang: Check if key exists in map
Proudly powered by WordPress