Andy, thank you. In case there would be a choice between ugly and achievable, I must take the last one:-)
Another thing I have found it that it is impossible to use type as a parameter when you call to a function. How to pass type to function argument in Go - Stack Overflow <https://stackoverflow.com/questions/51097211/how-to-pass-type-to-function-argument-in-go> Thank you. пятница, 17 марта 2023 г. в 02:12:22 UTC+3, Andy Balholm: > I would guess that in the case of AST nodes, you're likely more interested > in the *identity* of the nodes than their *values*. In that case, you > should use the pointers to the nodes as your map keys. > > If the *values* truly are what you care about, use the go/format package > to convert the node back to source code, and use the resulting string as > your map key. > > On Thursday, March 16, 2023 at 3:24:49 PM UTC-7 alex-coder wrote: > >> >> Sure, convert to a string and use that as a map key. >> :-) no, no, no. it looks very very ugly. >> >> четверг, 16 марта 2023 г. в 00:26:35 UTC+3, Ian Lance Taylor: >> >>> On Wed, Mar 15, 2023 at 2:16 PM alex-coder <a.gus...@gmail.com> wrote: >>> > >>> > Ian, thank you. >>> > but may be the is any workaround ? >>> > Use as a key not directly but like a derived from those >>> interface/structure types ? >>> > Of course I may declare key like string and use switch + .(type) to >>> mimic it. >>> >>> Sure, convert to a string and use that as a map key. >>> >>> By the way, I should say that although you can't use `ast.Field` as a >>> map key type, you can use `*ast.Field`. Of course then two different >>> Field values that happen to look exactly the same will get different >>> map entries. So it kind of depends on what you want to do. >>> >>> Ian >>> >> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/b6ea9156-f4fd-4cf9-9a51-5942f5cbe715n%40googlegroups.com.