How do you get the name of a constant given its value ?
More specifically (and to get a more readable understanding), I\'m working with the crypto/tls
packa
I am afraid that is not possible.
The constants are resolved at compile time and there is nothing in the reflect
package that allows you to retrieve the name.
What I suggest is creating a map with the names:
var constLookup = map[uint16]string{
tls.TLS_RSA_WITH_RC4_128_SHA: `TLS_RSA_WITH_RC4_128_SHA`,
tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA: `TLS_RSA_WITH_3DES_EDE_CBC_SHA`,
...
}