TGViewer
Igor Panasyuk | IGORoutine Programming Igor Panasyuk | IGORoutine Programming @igoroutine · 2.21K subscribers
Post #51 2.8K
Что будет выведено в stdout?

С точки зрения стандарта языка:
The comparison operators == and != must be fully defined for operands of the key type; thus the key type must not be a function, map, or slice. If the key type is an interface (то есть any) type, these comparison operators must be defined for the dynamic key values; failure will cause a run-time panic.

В текущем случае тип Key это произведение типов int и func. Поскольку в произведении типов присутствует тип func, то
Key не имеет операторов сравнения != и ==. Поэтому, согласно стандарту, получаем панику:

panic: runtime error: hash of unhashable type main.Key

https://go.dev/play/p/YgAgjKr6Jhp
go.dev Go Playground - The Go Programming Language
  • ❤ 13
  • 🔥 4
More from @igoroutine
  1. Sep 29, 2026Отправляешь очередной промпт нейронке и ловишь себя на мысли: «Я - какой-то ненастоящий пр…
  2. Jul 13, 2026Доброго вечера и хорошей недели)) На ней выйдут два новых видео. Рассвет сегодня не заснял…
  3. Jul 6, 2026Доброе утро и хорошей недели
  4. Jul 4, 2026AI заменит образование? В последнее время в индустрии очень остро стоит вопрос о смысле тр…
  5. Jul 1, 2026Без этих знаний твой Go-вайбкод положит прод | Пакет sync изнутри Давно обещал выпустить п…
  6. Jun 29, 2026Доброе утро и хорошей недели
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →