Skip to content

Remove deprecated github.com/pkg/errors module #697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions datadictionary/datadictionary.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package datadictionary

import (
"encoding/xml"
"fmt"
"io"
"os"

"github.com/pkg/errors"
)

// DataDictionary models FIX messages, components, and fields.
Expand Down Expand Up @@ -304,7 +303,7 @@ func Parse(path string) (*DataDictionary, error) {
var err error
xmlFile, err = os.Open(path)
if err != nil {
return nil, errors.Wrapf(err, "problem opening file: %v", path)
return nil, fmt.Errorf("problem opening file: %s: %w", path, err)
}
defer xmlFile.Close()

Expand All @@ -320,7 +319,7 @@ func ParseSrc(xmlSrc io.Reader) (*DataDictionary, error) {
}

if err := decoder.Decode(doc); err != nil {
return nil, errors.Wrapf(err, "problem parsing XML file")
return nil, fmt.Errorf("problem parsing XML file: %w", err)
}

b := new(builder)
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.23
require (
github.com/mattn/go-sqlite3 v1.14.22
github.com/pires/go-proxyproto v0.7.0
github.com/pkg/errors v0.9.1
github.com/quagmt/udecimal v1.8.0
github.com/shopspring/decimal v1.4.0
github.com/stretchr/testify v1.9.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ github.com/montanaflynn/stats v0.6.6 h1:Duep6KMIDpY4Yo11iFsvyqJDyfzLF9+sndUKT+v6
github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/pires/go-proxyproto v0.7.0 h1:IukmRewDQFWC7kfnb66CSomk2q/seBuilHBYFwyq0Hs=
github.com/pires/go-proxyproto v0.7.0/go.mod h1:Vz/1JPY/OACxWGQNIRY2BeyDmpoaWmEP40O9LbuiFR4=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/quagmt/udecimal v1.8.0 h1:d4MJNGb/dg8r03AprkeSiDlVKtkZnL10L3de/YGOiiI=
Expand Down
6 changes: 3 additions & 3 deletions internal/time_range.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package internal

import (
"errors"
"fmt"
"time"

"github.com/pkg/errors"
)

// TimeOfDay represents the time of day.
Expand All @@ -27,7 +27,7 @@ func NewTimeOfDay(hour, minute, second int) TimeOfDay {
func ParseTimeOfDay(str string) (TimeOfDay, error) {
t, err := time.Parse(shortForm, str)
if err != nil {
return TimeOfDay{}, errors.Wrap(err, "time must be in the format HH:MM:SS")
return TimeOfDay{}, fmt.Errorf("time must be in the format HH:MM:SS: %w", err)
}

return NewTimeOfDay(t.Clock()), nil
Expand Down
3 changes: 1 addition & 2 deletions log/mongo/mongo_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"log"
"time"

"github.com/pkg/errors"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
Expand Down Expand Up @@ -214,7 +213,7 @@ func (l *mongoLog) close() error {
if l.db != nil {
err := l.db.Disconnect(context.Background())
if err != nil {
return errors.Wrap(err, "error disconnecting from database")
return fmt.Errorf("error disconnecting from database: %w", err)
}
l.db = nil
}
Expand Down
5 changes: 2 additions & 3 deletions memory_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
package quickfix

import (
"fmt"
"time"

"github.com/pkg/errors"
)

type memoryStore struct {
Expand Down Expand Up @@ -122,7 +121,7 @@ type memoryStoreFactory struct{}
func (f memoryStoreFactory) Create(_ SessionID) (MessageStore, error) {
m := new(memoryStore)
if err := m.Reset(); err != nil {
return m, errors.Wrap(err, "reset")
return m, fmt.Errorf("reset: %w", err)
}
return m, nil
}
Expand Down
40 changes: 20 additions & 20 deletions session_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
package quickfix

import (
"errors"
"fmt"
"net"
"strconv"
"strings"
"time"

"github.com/pkg/errors"

"github.com/quickfixgo/quickfix/config"
"github.com/quickfixgo/quickfix/datadictionary"
"github.com/quickfixgo/quickfix/internal"
Expand Down Expand Up @@ -132,17 +132,17 @@ func (f sessionFactory) newSession(
}

if s.transportDataDictionary, err = datadictionary.Parse(transportDataDictionaryPath); err != nil {
err = errors.Wrapf(
err, "problem parsing XML datadictionary path '%v' for setting '%v",
settings.settings[config.TransportDataDictionary], config.TransportDataDictionary,
err = fmt.Errorf(
"problem parsing XML datadictionary path '%v' for setting '%v': %w",
settings.settings[config.TransportDataDictionary], config.TransportDataDictionary, err,
)
return
}

if s.appDataDictionary, err = datadictionary.Parse(appDataDictionaryPath); err != nil {
err = errors.Wrapf(
err, "problem parsing XML datadictionary path '%v' for setting '%v",
settings.settings[config.AppDataDictionary], config.AppDataDictionary,
err = fmt.Errorf(
"problem parsing XML datadictionary path '%v' for setting '%v': %w",
settings.settings[config.AppDataDictionary], config.AppDataDictionary, err,
)
return
}
Expand All @@ -156,9 +156,9 @@ func (f sessionFactory) newSession(
}

if s.appDataDictionary, err = datadictionary.Parse(dataDictionaryPath); err != nil {
err = errors.Wrapf(
err, "problem parsing XML datadictionary path '%v' for setting '%v",
settings.settings[config.DataDictionary], config.DataDictionary,
err = fmt.Errorf(
"problem parsing XML datadictionary path '%v' for setting '%v': %w",
settings.settings[config.DataDictionary], config.DataDictionary, err,
)
return
}
Expand Down Expand Up @@ -245,17 +245,17 @@ func (f sessionFactory) newSession(

var start, end internal.TimeOfDay
if start, err = internal.ParseTimeOfDay(startTimeStr); err != nil {
err = errors.Wrapf(
err, "problem parsing time of day '%v' for setting '%v",
settings.settings[config.StartTime], config.StartTime,
err = fmt.Errorf(
"problem parsing time of day '%v' for setting '%v': %w",
settings.settings[config.StartTime], config.StartTime, err,
)
return
}

if end, err = internal.ParseTimeOfDay(endTimeStr); err != nil {
err = errors.Wrapf(
err, "problem parsing time of day '%v' for setting '%v",
settings.settings[config.EndTime], config.EndTime,
err = fmt.Errorf(
"problem parsing time of day '%v' for setting '%v': %w",
settings.settings[config.EndTime], config.EndTime, err,
)
return
}
Expand All @@ -269,9 +269,9 @@ func (f sessionFactory) newSession(

loc, err = time.LoadLocation(locStr)
if err != nil {
err = errors.Wrapf(
err, "problem parsing time zone '%v' for setting '%v",
settings.settings[config.TimeZone], config.TimeZone,
err = fmt.Errorf(
"problem parsing time zone '%v' for setting '%v': %w",
settings.settings[config.TimeZone], config.TimeZone, err,
)
return
}
Expand Down
26 changes: 13 additions & 13 deletions store/file/file_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package file

import (
"errors"
"fmt"
"io"
"os"
Expand All @@ -25,7 +26,6 @@ import (
"sync"
"time"

"github.com/pkg/errors"
"github.com/quickfixgo/quickfix"
"github.com/quickfixgo/quickfix/config"
)
Expand Down Expand Up @@ -96,7 +96,7 @@ func newFileStore(sessionID quickfix.SessionID, dirname string, fileSync bool) (

memStore, memErr := quickfix.NewMemoryStoreFactory().Create(sessionID)
if memErr != nil {
return nil, errors.Wrap(memErr, "cache creation")
return nil, fmt.Errorf("cache creation: %w", memErr)
}

store := &fileStore{
Expand All @@ -120,11 +120,11 @@ func newFileStore(sessionID quickfix.SessionID, dirname string, fileSync bool) (
// Reset deletes the store files and sets the seqnums back to 1.
func (store *fileStore) Reset() error {
if err := store.cache.Reset(); err != nil {
return errors.Wrap(err, "cache reset")
return fmt.Errorf("cache reset: %w", err)
}

if err := store.Close(); err != nil {
return errors.Wrap(err, "close")
return fmt.Errorf("close: %w", err)
}
if err := removeFile(store.bodyFname); err != nil {
return err
Expand All @@ -147,7 +147,7 @@ func (store *fileStore) Reset() error {
// Refresh closes the store files and then reloads from them.
func (store *fileStore) Refresh() (err error) {
if err = store.cache.Reset(); err != nil {
err = errors.Wrap(err, "cache reset")
err = fmt.Errorf("cache reset: %w", err)
return
}

Expand Down Expand Up @@ -183,11 +183,11 @@ func (store *fileStore) Refresh() (err error) {
}

if err := store.SetNextSenderMsgSeqNum(store.NextSenderMsgSeqNum()); err != nil {
return errors.Wrap(err, "set next sender")
return fmt.Errorf("set next sender: %w", err)
}

if err := store.SetNextTargetMsgSeqNum(store.NextTargetMsgSeqNum()); err != nil {
return errors.Wrap(err, "set next target")
return fmt.Errorf("set next target: %w", err)
}
return nil
}
Expand All @@ -204,15 +204,15 @@ func (store *fileStore) populateCache() (creationTimePopulated bool, err error)
if senderSeqNumBytes, err := os.ReadFile(store.senderSeqNumsFname); err == nil {
if senderSeqNum, err := strconv.Atoi(strings.Trim(string(senderSeqNumBytes), "\r\n")); err == nil {
if err = store.cache.SetNextSenderMsgSeqNum(senderSeqNum); err != nil {
return creationTimePopulated, errors.Wrap(err, "cache set next sender")
return creationTimePopulated, fmt.Errorf("cache set next sender: %w", err)
}
}
}

if targetSeqNumBytes, err := os.ReadFile(store.targetSeqNumsFname); err == nil {
if targetSeqNum, err := strconv.Atoi(strings.Trim(string(targetSeqNumBytes), "\r\n")); err == nil {
if err = store.cache.SetNextTargetMsgSeqNum(targetSeqNum); err != nil {
return creationTimePopulated, errors.Wrap(err, "cache set next target")
return creationTimePopulated, fmt.Errorf("cache set next target: %w", err)
}
}
}
Expand Down Expand Up @@ -273,31 +273,31 @@ func (store *fileStore) NextTargetMsgSeqNum() int {
// SetNextSenderMsgSeqNum sets the next MsgSeqNum that will be sent.
func (store *fileStore) SetNextSenderMsgSeqNum(next int) error {
if err := store.setSeqNum(store.senderSeqNumsFile, next); err != nil {
return errors.Wrap(err, "file")
return fmt.Errorf("file: %w", err)
}
return store.cache.SetNextSenderMsgSeqNum(next)
}

// SetNextTargetMsgSeqNum sets the next MsgSeqNum that should be received.
func (store *fileStore) SetNextTargetMsgSeqNum(next int) error {
if err := store.setSeqNum(store.targetSeqNumsFile, next); err != nil {
return errors.Wrap(err, "file")
return fmt.Errorf("file: %w", err)
}
return store.cache.SetNextTargetMsgSeqNum(next)
}

// IncrNextSenderMsgSeqNum increments the next MsgSeqNum that will be sent.
func (store *fileStore) IncrNextSenderMsgSeqNum() error {
if err := store.SetNextSenderMsgSeqNum(store.cache.NextSenderMsgSeqNum() + 1); err != nil {
return errors.Wrap(err, "file")
return fmt.Errorf("file: %w", err)
}
return nil
}

// IncrNextTargetMsgSeqNum increments the next MsgSeqNum that should be received.
func (store *fileStore) IncrNextTargetMsgSeqNum() error {
if err := store.SetNextTargetMsgSeqNum(store.cache.NextTargetMsgSeqNum() + 1); err != nil {
return errors.Wrap(err, "file")
return fmt.Errorf("file: %w", err)
}
return nil
}
Expand Down
3 changes: 1 addition & 2 deletions store/file/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"os"
"strings"

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

Expand Down Expand Up @@ -68,7 +67,7 @@ func closeSyncFile(f *os.File) error {
// removeFile behaves like os.Remove, except that no error is returned if the file does not exist.
func removeFile(fname string) error {
if err := os.Remove(fname); (err != nil) && !os.IsNotExist(err) {
return errors.Wrapf(err, "remove %v", fname)
return fmt.Errorf("remove %v: %w", fname, err)
}
return nil
}
Expand Down
Loading
Loading