Skip to content
Advertisement

Tag: go

Problem reading uniqueidentifier from SQL response

I have tried to find the solution for this problem, but keep running my head at the wall with this one. This function is part of a Go SQL wrapper, and the function getJSON is called to extract the informations from the sql response. The problem is, that the id parameter becomes jibberish and does not match the desired response,

How do I create a structure for a dynamic SQL query?

In my Golang application I make SQL request to the database. Usually, in the SQL query, I specify the columns that I want to get from the table and create a structure based on it. You can see an example of the working code below. QUESTION: What should I do if I don’t know the number and name of columns

Scan row into slice

I want to Scan a sql.Row into a slice like so: but I am getting this error: 2020/02/23 20:05:14 raw query: SELECT * FROM user_table LIMIT 500 2020/02/23 20:05:14 sql: expected 6 destination arguments in Scan, not 0 anyone know how to make this generic without using a slice? Answer You can do it this way: on the internet they

Golang db query using slice IN clause

Can someone explain to me why this does not work? And this does I’m trying to do a simple IN clause with a slice of ints, and every solution suggested doesn’t seem very idiomatic Tried to do this, but the problem appears to be the string substitution. I’m a bit surprised that go doesn’t seem to have a graceful way

Advertisement