Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: unsupported key type *foo #53

Open
jeremy-giaco opened this issue Jul 3, 2021 · 3 comments
Open

panic: unsupported key type *foo #53

jeremy-giaco opened this issue Jul 3, 2021 · 3 comments

Comments

@jeremy-giaco
Copy link

jeremy-giaco commented Jul 3, 2021

Apparently it is not currently possible to add a reference to a struct as a key in the hashmap. This is valid in the native map, sync.Map, etc.

In this example, i create an "Attribute" and "Value" struct, then try to create a map of key: *Attribute, value:*Value...
https://play.golang.org/p/m2RkogzD-82

Error returned is: panic: unsupported key type *main.Attribute

@jeremy-giaco
Copy link
Author

jeremy-giaco commented Jul 3, 2021

Of note, i could use the "Attribute.ID" in my example as the key of the hashmap, then use the *Value as the value, but since in my code I am already looking up the attribute by Name, i have no desire to dereference it in order to get it's ID before interogating the map for values of a certain Attribute/Value combination.

Also of note, I'm pretty new to Go, and don't really know what i'm doing, lol.

@tigrato
Copy link
Contributor

tigrato commented Dec 29, 2021

@jeremy-giaco the issue is triggered when trying to compute the hash for the key. This lib supports the following keys

func getKeyHash(key interface{}) uintptr {

sync.Map uses the internal map hash function which dereferences the pointer and uses memory value to compute the hash which this lib does not support

@kant777
Copy link

kant777 commented Feb 21, 2022

still not supported?

Repository owner deleted a comment from hello-100 Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants