I am handling user auth data posted to my Go backend through an HTML form. I am building on some boilerplate to learn Go better. My problem is what the following func returns: func (ctrl …
Tag: go
Making dynamic SQL queries to a MySQL DB
I’ve never used golang with mysql before, so I’m reading about these for the first time. I’d like to do something like this: This is far too much typing, especially if I have a dozen more variables I’d like to add to the WHERE condition. If this were PHP, I’d do something like this: By using a foreach loop, I
Checking if a value exists in sqlite db with Go
I’m writing code to manage users in a sqlite database with Go. I’m trying to check if a username is taken, but my code is ugly. My table looks like: And I check if a username is taken with: Is there a better query I could use that would tell me if the username value exists in the table in
sql: scan row(s) with unknown number of columns (select * from …)
I have a table t containing a lot of columns, and my sql is like this: select * from t. Now I only want to scan one column or two from the wide returned row set. However, the sql.Scan accepts dest ……
Is there a way to get the Type for a Column using package database/sql in golang?
Basically, without knowing before hand what the resulting structure of a query might be, I’d like to query the database, and return a structure like this (json-y) Is there a way to get the Type for a Column using package database/sql in golang? I’m suspecting that what I want to do is make an array of interface{} the size of