Advertisement
zergon321

typed nil #1

Apr 22nd, 2023
1,269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.28 KB | Source Code | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5. )
  6.  
  7. type Man struct {
  8.     Name string
  9. }
  10.  
  11. type Woman struct {
  12.     Name string
  13. }
  14.  
  15. func main() {
  16.     types := map[interface{}]string{}
  17.  
  18.     var (
  19.         man   *Man
  20.         woman *Woman
  21.     )
  22.  
  23.     types[man] = "man"
  24.     types[woman] = "woman"
  25.  
  26.     fmt.Println(types)
  27. }
Tags: go golang
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement