goqu icon indicating copy to clipboard operation
goqu copied to clipboard

Can slice as a parameter to select?

Open tony0804 opened this issue 3 years ago • 2 comments

Hi First of all, thank you very much for providing such a great tool. col := []string{"a","b"} goqu.From("test").Select(col) Can slice as a parameter to select? The values of the columns are passed from the front end (the user can choose which columns to display) so I need to pass the parameters through the slices. Best Regards Tony

tony0804 avatar Feb 03 '22 02:02 tony0804

You could set you slice and pass it in variadic (<slice>...) fashion:

col := []string{"a","b"}
goqu.From("test").Select(col...)

See also WithStruct example at https://pkg.go.dev/github.com/doug-martin/goqu/v9#SelectDataset.Select which may be more useful to you.

funkyshu avatar Feb 03 '22 09:02 funkyshu