chore: remove dependency on "hashicorp/go-multierror" (#1322)

* feat: remove dependency on "hashicorp/go-multierror"

It seems the project has been unmainted for quite some time already,
see for example https://github.com/hashicorp/go-multierror/issues/97
and https://github.com/hashicorp/go-multierror/issues/98.
This also removes an uneccessary dependency which slims down the go.mod.

Go as of version 1.20 supports appending errors by specifying
multiple "%w" formatters in the "fmt.Errorf"[^0] function.

[^0]: https://pkg.go.dev/fmt#Errorf

* feat: use errors.Join to combine multiple errors

As an update to the previous commit 59f084ea3be2e7ec9d912c1a311402b1e4c40df6,
use "errors.Join"[^0] instead of multiple "%w" formatters for "fmt.Errorf".

[^0]: https://pkg.go.dev/errors#Join

* chore: bring back unused util.go file as removing it is a breaking change
This commit is contained in:
leonklingele
2025-11-29 11:37:42 -08:00
committed by GitHub
parent d55bf07848
commit 426470006b
25 changed files with 89 additions and 177 deletions
+5 -9
View File
@@ -2,6 +2,7 @@ package sqlcipher
import (
"database/sql"
"errors"
"fmt"
"io"
nurl "net/url"
@@ -11,7 +12,6 @@ import (
"github.com/golang-migrate/migrate/v4"
"github.com/golang-migrate/migrate/v4/database"
"github.com/hashicorp/go-multierror"
_ "github.com/mutecomm/go-sqlcipher/v4"
)
@@ -72,11 +72,7 @@ func (m *Sqlite) ensureVersionTable() (err error) {
defer func() {
if e := m.Unlock(); e != nil {
if err == nil {
err = e
} else {
err = multierror.Append(err, e)
}
err = errors.Join(err, e)
}
}()
@@ -140,7 +136,7 @@ func (m *Sqlite) Drop() (err error) {
}
defer func() {
if errClose := tables.Close(); errClose != nil {
err = multierror.Append(err, errClose)
err = errors.Join(err, errClose)
}
}()
@@ -210,7 +206,7 @@ func (m *Sqlite) executeQuery(query string) error {
}
if _, err := tx.Exec(query); err != nil {
if errRollback := tx.Rollback(); errRollback != nil {
err = multierror.Append(err, errRollback)
err = errors.Join(err, errRollback)
}
return &database.Error{OrigErr: err, Query: []byte(query)}
}
@@ -245,7 +241,7 @@ func (m *Sqlite) SetVersion(version int, dirty bool) error {
query := fmt.Sprintf(`INSERT INTO %s (version, dirty) VALUES (?, ?)`, m.config.MigrationsTable)
if _, err := tx.Exec(query, version, dirty); err != nil {
if errRollback := tx.Rollback(); errRollback != nil {
err = multierror.Append(err, errRollback)
err = errors.Join(err, errRollback)
}
return &database.Error{OrigErr: err, Query: []byte(query)}
}