Skip to content

Commit

Permalink
feat: remove deprecated package github.com/pkg/errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Oct 16, 2024
1 parent 073cd0d commit 96c977e
Show file tree
Hide file tree
Showing 81 changed files with 167 additions and 162 deletions.
10 changes: 5 additions & 5 deletions cmd/doc_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package cmd

import (
"encoding/json"
"fmt"
"github.com/formancehq/ledger/internal/bus"
"github.com/invopop/jsonschema"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"os"
"path/filepath"
Expand All @@ -21,12 +21,12 @@ func NewDocEventsCommand() *cobra.Command {

writeDir, err := cmd.Flags().GetString(writeDirFlag)
if err != nil {
return errors.Wrap(err, "failed to get write-dir flag")
return fmt.Errorf("failed to get write-dir flag: %w", err)
}

err = os.MkdirAll(writeDir, 0755)
if err != nil {
return errors.Wrap(err, "failed to create write-dir")
return fmt.Errorf("failed to create write-dir: %w", err)
}

for _, o := range []any{
Expand All @@ -38,11 +38,11 @@ func NewDocEventsCommand() *cobra.Command {
schema := jsonschema.Reflect(o)
data, err := json.MarshalIndent(schema, "", " ")
if err != nil {
return errors.Wrap(err, "failed to marshal schema")
return fmt.Errorf("failed to marshal schema: %w", err)
}
err = os.WriteFile(filepath.Join(writeDir, reflect.TypeOf(o).Name()+".json"), data, 0600)
if err != nil {
return errors.Wrap(err, "failed to write schema")
return fmt.Errorf("failed to write schema: %w", err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"context"
"errors"
"github.com/formancehq/ledger/internal/storage/driver"
"net/http"

Expand All @@ -20,7 +21,6 @@ import (
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
systemcontroller "github.com/formancehq/ledger/internal/controller/system"
"github.com/formancehq/ledger/internal/storage"
"github.com/pkg/errors"

"github.com/formancehq/go-libs/ballast"
"github.com/formancehq/go-libs/service"
Expand Down
2 changes: 1 addition & 1 deletion internal/api/common/middleware_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/platform/postgres"

"github.com/pkg/errors"
"errors"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/api/common/middleware_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"net/http/httptest"
"testing"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/logging"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
systemcontroller "github.com/formancehq/ledger/internal/controller/system"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/api/v1/controllers_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"
"strings"

"github.com/pkg/errors"
"errors"

"github.com/formancehq/go-libs/query"
ledger "github.com/formancehq/ledger/internal"
Expand Down
2 changes: 1 addition & 1 deletion internal/api/v1/controllers_accounts_add_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"net/http"
"net/url"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/metadata"
"github.com/formancehq/ledger/internal/api/common"
"github.com/go-chi/chi/v5"
"github.com/pkg/errors"
)

func addAccountMetadata(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion internal/api/v1/controllers_accounts_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"fmt"
"net/http"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/bun/bunpaginate"
"github.com/formancehq/go-libs/pointer"
"github.com/formancehq/ledger/internal/api/common"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/pkg/errors"
)

func countAccounts(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion internal/api/v1/controllers_accounts_count_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"net/url"
"testing"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/auth"
"github.com/formancehq/go-libs/query"
"github.com/formancehq/go-libs/time"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"net/url"
"testing"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/auth"
"github.com/formancehq/go-libs/logging"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/api/v1/controllers_accounts_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package v1
import (
"net/http"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/bun/bunpaginate"
"github.com/formancehq/go-libs/pointer"
"github.com/formancehq/ledger/internal/api/common"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/pkg/errors"
)

func listAccounts(w http.ResponseWriter, r *http.Request) {
Expand Down
4 changes: 2 additions & 2 deletions internal/api/v1/controllers_logs_list.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package v1

import (
"fmt"
"net/http"

"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/bun/bunpaginate"
"github.com/formancehq/go-libs/query"
"github.com/formancehq/ledger/internal/api/common"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/pkg/errors"
)

func buildGetLogsQuery(r *http.Request) (query.Builder, error) {
Expand Down Expand Up @@ -42,7 +42,7 @@ func getLogs(w http.ResponseWriter, r *http.Request) {
if r.URL.Query().Get(QueryKeyCursor) != "" {
err := bunpaginate.UnmarshalCursor(r.URL.Query().Get(QueryKeyCursor), &query)
if err != nil {
api.BadRequest(w, ErrValidation, errors.Errorf("invalid '%s' query param", QueryKeyCursor))
api.BadRequest(w, ErrValidation, fmt.Errorf("invalid '%s' query param: %w", QueryKeyCursor, err))
return
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion internal/api/v1/controllers_transactions_add_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (

ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/metadata"
"github.com/formancehq/ledger/internal/api/common"
"github.com/go-chi/chi/v5"
"github.com/pkg/errors"
)

func addTransactionMetadata(w http.ResponseWriter, r *http.Request) {
Expand Down
6 changes: 3 additions & 3 deletions internal/api/v1/controllers_transactions_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (

ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/metadata"
"github.com/formancehq/go-libs/time"
ledger "github.com/formancehq/ledger/internal"
"github.com/formancehq/ledger/internal/api/common"
"github.com/pkg/errors"
)

type Script struct {
Expand All @@ -38,11 +38,11 @@ func (s Script) ToCore() (*ledgercontroller.Script, error) {
// Is a monetary
var asset string
if err := json.Unmarshal(m["asset"], &asset); err != nil {
return nil, errors.Wrap(err, "unmarshalling asset")
return nil, fmt.Errorf("unmarshalling asset: %w", err)
}
amount := &big.Int{}
if err := json.Unmarshal(m["amount"], amount); err != nil {
return nil, errors.Wrap(err, "unmarshalling amount")
return nil, fmt.Errorf("unmarshalling amount: %w", err)
}

s.Script.Vars[k] = fmt.Sprintf("%s %s", asset, amount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (

ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/ledger/internal/api/common"
"github.com/go-chi/chi/v5"
"github.com/pkg/errors"
)

func deleteTransactionMetadata(w http.ResponseWriter, r *http.Request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"net/url"
"testing"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/auth"
"github.com/formancehq/go-libs/logging"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/api/v1/controllers_transactions_revert.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (

ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/ledger/internal/api/common"
"github.com/go-chi/chi/v5"
"github.com/pkg/errors"
)

func revertTransaction(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion internal/api/v1/middleware_auto_create_ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package v1
import (
"net/http"

"github.com/pkg/errors"
"errors"

"github.com/formancehq/ledger/internal/controller/system"

Expand Down
2 changes: 1 addition & 1 deletion internal/api/v2/controllers_accounts_add_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"net/http"
"net/url"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/metadata"
"github.com/formancehq/ledger/internal/api/common"
"github.com/go-chi/chi/v5"
"github.com/pkg/errors"
)

func addAccountMetadata(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion internal/api/v2/controllers_accounts_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"fmt"
"net/http"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/ledger/internal/api/common"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/pkg/errors"
)

func countAccounts(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion internal/api/v2/controllers_accounts_count_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"net/url"
"testing"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/auth"
"github.com/formancehq/go-libs/query"
"github.com/formancehq/go-libs/time"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"net/url"
"testing"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/auth"
"github.com/formancehq/go-libs/logging"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/api/v2/controllers_accounts_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package v2
import (
"net/http"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/bun/bunpaginate"
"github.com/formancehq/go-libs/pointer"
"github.com/formancehq/ledger/internal/api/common"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/pkg/errors"
)

func listAccounts(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion internal/api/v2/controllers_accounts_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/url"
"testing"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/auth"
"github.com/formancehq/go-libs/bun/bunpaginate"
Expand All @@ -15,7 +16,6 @@ import (
"github.com/formancehq/go-libs/time"
ledger "github.com/formancehq/ledger/internal"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/api/v2/controllers_balances.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package v2
import (
"net/http"

"errors"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/pkg/errors"

"github.com/formancehq/go-libs/api"
"github.com/formancehq/ledger/internal/api/common"
Expand Down
2 changes: 1 addition & 1 deletion internal/api/v2/controllers_bulk.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"fmt"
"net/http"

"errors"
"github.com/formancehq/go-libs/metadata"
ledger "github.com/formancehq/ledger/internal"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
"github.com/formancehq/ledger/internal/tracing"
"github.com/pkg/errors"

"github.com/formancehq/go-libs/api"
"github.com/formancehq/ledger/internal/api/common"
Expand Down
2 changes: 1 addition & 1 deletion internal/api/v2/controllers_bulk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import (

"github.com/formancehq/go-libs/time"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/auth"
"github.com/formancehq/go-libs/metadata"
ledger "github.com/formancehq/ledger/internal"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/api/v2/controllers_ledgers_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (

ledger "github.com/formancehq/ledger/internal"

"errors"
"github.com/formancehq/go-libs/api"
"github.com/go-chi/chi/v5"
"github.com/pkg/errors"
)

func createLedger(systemController system.Controller) http.HandlerFunc {
Expand Down
Loading

0 comments on commit 96c977e

Please sign in to comment.