• Something interesting happened to me today. Nasty bug because I accidentally returned nil instead of err when err != nil, so it took me a while to find:
{
  "error": "sql: Scan error on column index 5, name \"user_id\": converting driver.Value type float64 (\"1.0160211027267435e+20\") to a int64: invalid syntax",
  "message": "Internal Server Error"
}
  • I am not sure what caused this, but hopefully will remember to write here what happened!
  • I suspect it has something to do with my changing the id params type to an interface instead of integer but I thought any risk of doing so would be confined to the scope in which params was made; I did not think it could somehow infiltrate all the way down into SQL code.
  • It looks like it’s interpreting the user ID as a float. So that’s an issue. The bigger question is why is the userID getting passed in instead of the termID?
  • Ok, the problem was very simple, and had nothing to do with the above. I hand’t changed the Term’s UserID field from int to string, so it was trying to read the number to an int. 🤦🏻‍♂️