I am using a 3rd party package, which allows you to create structures of a certain non-exported type through an exported function.
package squirrel
type expr struct {
sql string
args []interface{}
}
func Expr(sql string, args ...interface{}) expr {
return expr{sql: sql, args: args}
}
Because of the way some other function of this library accepts data, I ended up with such a map:
m := map[string]interface{} {
"col1": 123,
"col2": "a_string",
"col3": Expr("now()"),
}
but because of a different function in this library I need to filter out all squirrel.expr
from this map.
Obviously, I wasn't able to assert the type directly, by doing so:
filtered := make(map[string]interface{})
for k, v := range m {
switch v.(type) {
case squirrel.expr:
continue
default:
filtered[k] = v
}
}
Is there another way to achieve the same result?