diff --git a/cmd/lint-commit-or-rollback/go.mod b/cmd/lint-commit-or-rollback/go.mod index c000a843ce..351e6edef6 100644 --- a/cmd/lint-commit-or-rollback/go.mod +++ b/cmd/lint-commit-or-rollback/go.mod @@ -4,13 +4,6 @@ go 1.22.0 require golang.org/x/tools v0.24.0 -require ( - github.com/alecthomas/repr v0.4.0 // indirect - github.com/hexops/gotextdiff v1.0.3 // indirect - golang.org/x/sync v0.8.0 // indirect -) +require golang.org/x/sync v0.8.0 // indirect -require ( - github.com/alecthomas/assert/v2 v2.10.0 - golang.org/x/mod v0.20.0 // indirect -) +require golang.org/x/mod v0.20.0 // indirect diff --git a/cmd/lint-commit-or-rollback/go.sum b/cmd/lint-commit-or-rollback/go.sum index 23f6abe190..5b7f1f0a60 100644 --- a/cmd/lint-commit-or-rollback/go.sum +++ b/cmd/lint-commit-or-rollback/go.sum @@ -1,11 +1,5 @@ -github.com/alecthomas/assert/v2 v2.10.0 h1:jjRCHsj6hBJhkmhznrCzoNpbA3zqy0fYiUcYZP/GkPY= -github.com/alecthomas/assert/v2 v2.10.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= -github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= -github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= diff --git a/cmd/lint-commit-or-rollback/main_test.go b/cmd/lint-commit-or-rollback/main_test.go deleted file mode 100644 index 430af58672..0000000000 --- a/cmd/lint-commit-or-rollback/main_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "os" - "os/exec" - "strings" - "testing" - - "github.com/alecthomas/assert/v2" -) - -func TestLinter(t *testing.T) { - pwd, err := os.Getwd() - assert.NoError(t, err) - cmd := exec.Command("lint-commit-or-rollback", ".") - cmd.Dir = "testdata" - output, err := cmd.CombinedOutput() - assert.Error(t, err) - expected := ` -` + pwd + `/testdata/main.go:35:29: defer tx.CommitOrRollback(&err) should be deferred with a reference to a named error return parameter, but the function at /Users/alec/dev/pfi/cmd/lint-commit-or-rollback/testdata/main.go:29:6 has no named return parameters -` + pwd + `/testdata/main.go:44:28: defer tx.CommitOrRollback(&err) should be deferred with a reference to a named error return parameter, but the function at /Users/alec/dev/pfi/cmd/lint-commit-or-rollback/testdata/main.go:28:1 has no named return parameters -` + pwd + `/testdata/main.go:55:29: defer tx.CommitOrRollback(&err) should be deferred with a reference to a named error return parameter, but the function at /Users/alec/dev/pfi/cmd/lint-commit-or-rollback/testdata/main.go:49:6 has no named return parameters - ` - assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(string(output))) -} diff --git a/cmd/lint-commit-or-rollback/testdata/go.mod b/cmd/lint-commit-or-rollback/testdata/go.mod deleted file mode 100644 index 1e35d08e48..0000000000 --- a/cmd/lint-commit-or-rollback/testdata/go.mod +++ /dev/null @@ -1,7 +0,0 @@ -module main - -go 1.22.2 - -replace pfi/backend => ../../../backend - -require pfi/backend v0.0.0-00010101000000-000000000000 diff --git a/cmd/lint-commit-or-rollback/testdata/go.sum b/cmd/lint-commit-or-rollback/testdata/go.sum deleted file mode 100644 index 07c3ecb203..0000000000 --- a/cmd/lint-commit-or-rollback/testdata/go.sum +++ /dev/null @@ -1,34 +0,0 @@ -github.com/alecthomas/assert/v2 v2.5.0 h1:OJKYg53BQx06/bMRBSPDCO49CbCDNiUQXwdoNrt6x5w= -github.com/alecthomas/assert/v2 v2.5.0/go.mod h1:fw5suVxB+wfYJ3291t0hRTqtGzFYdSwstnRQdaQx2DM= -github.com/alecthomas/repr v0.3.0 h1:NeYzUPfjjlqHY4KtzgKJiWd6sVq2eNUPTi34PiFGjY8= -github.com/alecthomas/repr v0.3.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= -github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= -github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= -github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= -github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= -github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= -github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= -github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= -github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI= -modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4= -modernc.org/libc v1.41.0 h1:g9YAc6BkKlgORsUWj+JwqoB1wU3o4DE3bM3yvA3k+Gk= -modernc.org/libc v1.41.0/go.mod h1:w0eszPsiXoOnoMJgrXjglgLuDy/bt5RR4y3QzUUeodY= -modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= -modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= -modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E= -modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E= -modernc.org/sqlite v1.29.1 h1:19GY2qvWB4VPw0HppFlZCPAbmxFU41r+qjKZQdQ1ryA= -modernc.org/sqlite v1.29.1/go.mod h1:hG41jCYxOAOoO6BRK66AdRlmOcDzXf7qnwlwjUIOqa0= -modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA= -modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0= -modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= -modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= diff --git a/cmd/lint-commit-or-rollback/testdata/main.go b/cmd/lint-commit-or-rollback/testdata/main.go deleted file mode 100644 index 5d87b35f00..0000000000 --- a/cmd/lint-commit-or-rollback/testdata/main.go +++ /dev/null @@ -1,70 +0,0 @@ -package main - -import ( - "context" - "database/sql" - - libdal "pfi/backend/libs/dal" -) - -type Tx struct { - *libdal.Tx[Tx] - *DAL -} - -// DAL is the data access layer for the IDV module. -type DAL struct { - db libdal.Conn - *libdal.DAL[Tx] -} - -// NewDAL creates a new Data Access Layer instance. -func NewDAL(conn *sql.DB) *DAL { - return &DAL{db: conn, DAL: libdal.New(conn, func(tx *sql.Tx, t *libdal.Tx[Tx]) *Tx { - return &Tx{DAL: &DAL{db: tx, DAL: t.DAL}, Tx: t} - })} -} - -func failure() error { - _ = func() error { - dal := DAL{} - tx, err := dal.Begin(context.Background()) - if err != nil { - return err - } - defer tx.CommitOrRollback(&err) // Should error - return nil - } - - dal := DAL{} - tx, err := dal.Begin(context.Background()) - if err != nil { - return err - } - defer tx.CommitOrRollback(&err) // Should error - return nil -} - -func success() (err error) { - _ = func() error { - dal := DAL{} - tx, err := dal.Begin(context.Background()) - if err != nil { - return err - } - defer tx.CommitOrRollback(&err) // Should error - return nil - } - dal := DAL{} - tx, err := dal.Begin(context.Background()) - if err != nil { - return err - } - defer tx.CommitOrRollback(&err) // Should NOT error - return nil -} - -func main() { - _ = failure() - _ = success() -}