I am trying to pass a list of values to the 'IN' expression in aws-sdk-go-v2 and I cannot figure out how to do it dynamically.
This is what it looks like now.
func Find(colors []string) ([]Trip, error) {
db := database.GetClient()
filt := expression.In(
expression.Name("color"),
expression.Value(colors[0]),
expression.Value(colors[1]),
)
expr, err := expression.NewBuilder().WithFilter(filt).Build()
if err != nil {
fmt.Println(err)
}
params := &dynamodb.ScanInput{
ExpressionAttributeNames: expr.Names(),
ExpressionAttributeValues: expr.Values(),
FilterExpression: expr.Filter(),
TableName: aws.String("Test"),
}
resp, err := db.Scan(context.TODO(), params)
}
I'd like to make the list values dynamic without accessing using their index. Like below,
filt := expression.In(expression.Name("color"),expression.Value(colors))
How can I achieve this?