diff --git a/.github/workflows/gha-go-test.yaml b/.github/workflows/gha-go-test.yaml index 7672158d..e52f5a40 100644 --- a/.github/workflows/gha-go-test.yaml +++ b/.github/workflows/gha-go-test.yaml @@ -10,6 +10,8 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.23 + - name: Run vet + run: make vet - name: Run staticcheck env: SC_VERSION: "2024.1" diff --git a/Makefile b/Makefile index 9c0d14b5..78c99e80 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,7 @@ +.PHONY: vet +vet: + go vet ./... + .PHONY: static static: staticcheck ./... diff --git a/integration_tests/mongo/main.go b/integration_tests/mongo/main.go index f3c2862c..a0a4e811 100644 --- a/integration_tests/mongo/main.go +++ b/integration_tests/mongo/main.go @@ -4,6 +4,12 @@ import ( "context" "encoding/json" "fmt" + "log/slog" + "math/rand/v2" + "os" + "reflect" + "time" + "github.com/artie-labs/reader/config" "github.com/artie-labs/reader/integration_tests/utils" "github.com/artie-labs/reader/lib" @@ -16,11 +22,6 @@ import ( "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "log/slog" - "math/rand/v2" - "os" - "reflect" - "time" ) func main() { @@ -96,25 +97,25 @@ func testTypes(ctx context.Context, db *mongo.Database, mongoCfg config.MongoDB) ts := time.Date(2020, 10, 5, 12, 0, 0, 0, time.UTC) _, err = collection.InsertOne(ctx, bson.D{ - {"_id", objId}, - {"string", "This is a string"}, - {"int32", int32(32)}, - {"int64", int64(64)}, - {"double", 3.14}, - {"bool", true}, - {"datetime", ts}, - {"embeddedDocument", bson.D{ - {"field1", "value1"}, - {"field2", "value2"}, + {Key: "_id", Value: objId}, + {Key: "string", Value: "This is a string"}, + {Key: "int32", Value: int32(32)}, + {Key: "int64", Value: int64(64)}, + {Key: "double", Value: 3.14}, + {Key: "bool", Value: true}, + {Key: "datetime", Value: ts}, + {Key: "embeddedDocument", Value: bson.D{ + {Key: "field1", Value: "value1"}, + {Key: "field2", Value: "value2"}, }}, - {"embeddedMap", bson.M{"foo": "bar", "hello": "world", "pi": 3.14159}}, - {"array", bson.A{"item1", 2, true, 3.14}}, - {"binary", []byte("binary data")}, - {"objectId", objId}, - {"null", nil}, - {"timestamp", primitive.Timestamp{T: uint32(ts.Unix()), I: 1}}, - {"minKey", primitive.MinKey{}}, - {"maxKey", primitive.MaxKey{}}, + {Key: "embeddedMap", Value: bson.M{"foo": "bar", "hello": "world", "pi": 3.14159}}, + {Key: "array", Value: bson.A{"item1", 2, true, 3.14}}, + {Key: "binary", Value: []byte("binary data")}, + {Key: "objectId", Value: objId}, + {Key: "null", Value: nil}, + {Key: "timestamp", Value: primitive.Timestamp{T: uint32(ts.Unix()), I: 1}}, + {Key: "minKey", Value: primitive.MinKey{}}, + {Key: "maxKey", Value: primitive.MaxKey{}}, }) if err != nil { return fmt.Errorf("failed to insert row: %w", err) diff --git a/sources/mongo/streaming.go b/sources/mongo/streaming.go index 5f4fc74d..b562a418 100644 --- a/sources/mongo/streaming.go +++ b/sources/mongo/streaming.go @@ -38,9 +38,9 @@ func newStreamingIterator(ctx context.Context, db *mongo.Database, cfg config.Mo // We only care about DMLs, the full list can be found here: https://www.mongodb.com/docs/manual/reference/change-events/ pipeline := mongo.Pipeline{ - {{"$match", bson.D{ - {"operationType", bson.D{ - {"$in", bson.A{"insert", "update", "delete", "replace"}}, + {{Key: "$match", Value: bson.D{ + {Key: "operationType", Value: bson.D{ + {Key: "$in", Value: bson.A{"insert", "update", "delete", "replace"}}, }}, }}}, }