I’ve question which is having 15 columns. Which is written by dba workforce.
Relaxation api workforce like to present solely 5 column to entrance finish developer.
However sqlx scan it choose ask for all columns.
The way to keep away from this case.
You may create a struct that’s a subset of these columns:
sort WideStruct struct {
ColumnIDontCareAbout int
ColumnIDoCareAbout int
//...
}
func (w WideStruct) ToSubStruct() SubStruct {
return SubStruct{
ColumnIDoCareAbout: w.ColumnIDoCareAbout,
}
}
sort SubStruct struct {
ColumnIDoCareAbout int
//...
}
The opposite straightforward choice is: simply use a customized MarshalJson:
You may additionally ditch sqlx for this question, and scan into native variables and simply populate the properties you want on some struct.