我创建了一个示例场景,如下所示。
func main() {
ids := []int{1, 2, 3}
var tmp []string
for _, v := range ids {
tmp = append(tmp, fmt.Sprint(v))
}
query := "SELECT * from table where id not in (" + strings.Join(tmp, ",") + ")"
fmt.Println(query)
}
或
你可以在go playground link中运行它