Skip to content

Commit

Permalink
all: remove github.com/pkg/errors dependency
Browse files Browse the repository at this point in the history
The github.com/pkg/errors package has been deprecated.

Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
  • Loading branch information
zchee committed Feb 13, 2022
1 parent 9cad061 commit eaf6740
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 19 deletions.
3 changes: 1 addition & 2 deletions block_conv.go
Expand Up @@ -2,9 +2,8 @@ package slack

import (
"encoding/json"
"errors"
"fmt"

"github.com/pkg/errors"
)

type sumtype struct {
Expand Down
5 changes: 2 additions & 3 deletions go.mod
@@ -1,12 +1,11 @@
module github.com/slack-go/slack

go 1.16

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-test/deep v1.0.4
github.com/gorilla/websocket v1.4.2
github.com/pkg/errors v0.8.0
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.2.2
)

go 1.16
2 changes: 0 additions & 2 deletions go.sum
Expand Up @@ -4,8 +4,6 @@ github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho=
github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/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/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
Expand Down
3 changes: 1 addition & 2 deletions socketmode/socketmode_test.go
Expand Up @@ -3,12 +3,11 @@ package socketmode
import (
"bytes"
"encoding/json"
"errors"
"reflect"
"testing"

"github.com/slack-go/slack/slackevents"

"github.com/pkg/errors"
)

const (
Expand Down
9 changes: 4 additions & 5 deletions webhooks_go112.go
Expand Up @@ -6,27 +6,26 @@ import (
"bytes"
"context"
"encoding/json"
"fmt"
"net/http"

"github.com/pkg/errors"
)

func PostWebhookCustomHTTPContext(ctx context.Context, url string, httpClient *http.Client, msg *WebhookMessage) error {
raw, err := json.Marshal(msg)
if err != nil {
return errors.Wrap(err, "marshal failed")
return fmt.Errorf("marshal failed: %v", err)
}

req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(raw))
if err != nil {
return errors.Wrap(err, "failed new request")
return fmt.Errorf("failed new request: %v", err)
}
req = req.WithContext(ctx)
req.Header.Set("Content-Type", "application/json")

resp, err := httpClient.Do(req)
if err != nil {
return errors.Wrap(err, "failed to post webhook")
return fmt.Errorf("failed to post webhook: %v", err)
}
defer resp.Body.Close()

Expand Down
9 changes: 4 additions & 5 deletions webhooks_go113.go
Expand Up @@ -6,26 +6,25 @@ import (
"bytes"
"context"
"encoding/json"
"fmt"
"net/http"

"github.com/pkg/errors"
)

func PostWebhookCustomHTTPContext(ctx context.Context, url string, httpClient *http.Client, msg *WebhookMessage) error {
raw, err := json.Marshal(msg)
if err != nil {
return errors.Wrap(err, "marshal failed")
return fmt.Errorf("marshal failed: %w", err)
}

req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(raw))
if err != nil {
return errors.Wrap(err, "failed new request")
return fmt.Errorf("failed new request: %w", err)
}
req.Header.Set("Content-Type", "application/json")

resp, err := httpClient.Do(req)
if err != nil {
return errors.Wrap(err, "failed to post webhook")
return fmt.Errorf("failed to post webhook: %w", err)
}
defer resp.Body.Close()

Expand Down

0 comments on commit eaf6740

Please sign in to comment.