I have function that looks like this
func GetMessage(id string, by string) error {
// mysql query goes here
}
I have message_id
which is string and id
which is primary key.
I would like to accept both types for id parameter.
I have tried like this
if (by == "id") {
int_id, err := strconv.ParseInt(id, 10, 64)
if err != nil {
panic(err)
}
id = int_id
}
But I'm getting error like
cannot use int_id (type int64) as type string in assignment
can someone help me?
Thanks