diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..6ee8016 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,44 @@ +run: + timeout: 10m + go: '1.22' + +linters: + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - typecheck + - unused + - unparam + - unconvert + - bodyclose + - decorder + - makezero + - nilnil + - nilerr + - rowserrcheck + - tenv + - wastedassign + - unparam + - misspell + - unconvert + - depguard + +issues: + exclude-use-default: true + exclude-case-sensitive: false + max-issues-per-linter: 50 + max-same-issues: 10 + new: false + +linters-settings: + depguard: + rules: + main: + files: + - $all + deny: + - pkg: "github.com/gofrs/uuid" + desc: 'use github.com/google/uuid instead' \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b451258 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 RudderStack + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sqlconnect/internal/base/tableadmin.go b/sqlconnect/internal/base/tableadmin.go index 231b7ab..3fb840d 100644 --- a/sqlconnect/internal/base/tableadmin.go +++ b/sqlconnect/internal/base/tableadmin.go @@ -183,7 +183,7 @@ func (db *DB) ListColumns(ctx context.Context, relation sqlconnect.RelationRef) // ListColumnsForSqlQuery returns a list of columns for the given sql query func (db *DB) ListColumnsForSqlQuery(ctx context.Context, sql string) ([]sqlconnect.ColumnRef, error) { var res []sqlconnect.ColumnRef - rows, err := db.DB.QueryContext(ctx, sql) + rows, err := db.DB.QueryContext(ctx, sql) // nolint:rowserrcheck if err != nil { return nil, fmt.Errorf("querying list columns for sql query: %w", err) } diff --git a/sqlconnect/internal/bigquery/driver/connection.go b/sqlconnect/internal/bigquery/driver/connection.go index 3b1764a..932a5c4 100644 --- a/sqlconnect/internal/bigquery/driver/connection.go +++ b/sqlconnect/internal/bigquery/driver/connection.go @@ -59,7 +59,7 @@ func (connection *bigQueryConnection) Begin() (driver.Tx, error) { return nil, fmt.Errorf("bigquery: transactions are not supported") } -func (connection *bigQueryConnection) query(query string) (*bigquery.Query, error) { +func (connection *bigQueryConnection) query(query string) (*bigquery.Query, error) { // nolint: unparam return connection.client.Query(query), nil } diff --git a/sqlconnect/internal/bigquery/driver/statement.go b/sqlconnect/internal/bigquery/driver/statement.go index 4055287..8f692a2 100644 --- a/sqlconnect/internal/bigquery/driver/statement.go +++ b/sqlconnect/internal/bigquery/driver/statement.go @@ -86,7 +86,7 @@ func (statement bigQueryStatement) buildQuery(args []driver.Value) (*bigquery.Qu return query, err } -func (statement bigQueryStatement) buildParameters(args []driver.Value) ([]bigquery.QueryParameter, error) { +func (statement bigQueryStatement) buildParameters(args []driver.Value) ([]bigquery.QueryParameter, error) { // nolint: unparam if args == nil { return nil, nil } diff --git a/sqlconnect/internal/bigquery/mappings.go b/sqlconnect/internal/bigquery/mappings.go index 1749b95..2e1d0f7 100644 --- a/sqlconnect/internal/bigquery/mappings.go +++ b/sqlconnect/internal/bigquery/mappings.go @@ -73,11 +73,11 @@ func jsonRowMapper(databaseTypeName string, value any) any { return v.Num().Int64() } case civil.Date: - return time.Date(int(v.Year), time.Month(v.Month), int(v.Day), 0, 0, 0, 0, time.UTC) + return time.Date(v.Year, v.Month, v.Day, 0, 0, 0, 0, time.UTC) case civil.Time: - return time.Date(0, 1, 1, int(v.Hour), int(v.Minute), int(v.Second), int(v.Nanosecond), time.UTC) + return time.Date(0, 1, 1, v.Hour, v.Minute, v.Second, v.Nanosecond, time.UTC) case civil.DateTime: - return time.Date(int(v.Date.Year), time.Month(v.Date.Month), int(v.Date.Day), int(v.Time.Hour), int(v.Time.Minute), int(v.Time.Second), int(v.Time.Nanosecond), time.UTC) + return time.Date(v.Date.Year, v.Date.Month, v.Date.Day, v.Time.Hour, v.Time.Minute, v.Time.Second, v.Time.Nanosecond, time.UTC) case *bigquery.IntervalValue: return v.ToDuration() case []uint8: