diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08e6cc6..e57de24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.25.7' + go-version: '1.25.x' cache: true - name: Download dependencies @@ -48,7 +48,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.25.7' + go-version: '1.25.x' cache: true - name: Build @@ -68,7 +68,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.25.7' + go-version: '1.25.x' cache: true - name: Check GoReleaser config diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8450b9e..1b517f5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.25.7' + go-version: '1.25.x' cache: true - name: Run GoReleaser diff --git a/go.mod b/go.mod index f9eef23..92172e1 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/shantoislamdev/kothaset -go 1.25.7 +go 1.24.1 require ( github.com/google/uuid v1.6.0 diff --git a/internal/cli/commands.go b/internal/cli/commands.go index f260962..786e9e3 100644 --- a/internal/cli/commands.go +++ b/internal/cli/commands.go @@ -210,9 +210,8 @@ func validateJSONL(path string) (int, error) { if line == "" { continue } - var obj map[string]any - if err := json.Unmarshal([]byte(line), &obj); err != nil { - return count, fmt.Errorf("line %d: invalid JSON: %w", lineNum, err) + if !json.Valid([]byte(line)) { + return count, fmt.Errorf("line %d: invalid JSON", lineNum) } count++ } diff --git a/internal/cli/commands_test.go b/internal/cli/commands_test.go index 0beb82f..689cfa7 100644 --- a/internal/cli/commands_test.go +++ b/internal/cli/commands_test.go @@ -69,3 +69,31 @@ global: t.Fatalf("expected config path validation to pass, got: %v", err) } } + +func BenchmarkValidateJSONL(b *testing.B) { + // Create a temporary JSONL file with 1000 lines + dir := b.TempDir() + path := filepath.Join(dir, "test.jsonl") + file, err := os.Create(path) + if err != nil { + b.Fatal(err) + } + + jsonLine := `{"id": "12345", "name": "John Doe", "email": "john.doe@example.com", "isActive": true, "roles": ["admin", "user"], "metadata": {"created_at": "2023-01-01T00:00:00Z", "login_count": 42}}` + "\n" + + for i := 0; i < 1000; i++ { + file.WriteString(jsonLine) + } + file.Close() + + b.ResetTimer() + for i := 0; i < b.N; i++ { + count, err := validateJSONL(path) + if err != nil { + b.Fatal(err) + } + if count != 1000 { + b.Fatalf("expected 1000 rows, got %d", count) + } + } +}