Skip to content
This repository was archived by the owner on Oct 5, 2023. It is now read-only.

Commit 4461a0b

Browse files
fix staticcheck
1 parent 3af3621 commit 4461a0b

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed

api.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"io/ioutil"
77
"net/http"
8-
gohttp "net/http"
98
"os"
109
"path/filepath"
1110
"strings"
@@ -14,7 +13,7 @@ import (
1413
caopts "github.com/ipfs/interface-go-ipfs-core/options"
1514
"github.com/mitchellh/go-homedir"
1615
ma "github.com/multiformats/go-multiaddr"
17-
manet "github.com/multiformats/go-multiaddr-net"
16+
manet "github.com/multiformats/go-multiaddr/net"
1817
)
1918

2019
const (
@@ -34,7 +33,7 @@ var ErrApiNotFound = errors.New("ipfs api address could not be found")
3433
// https://godoc.org/github.com/ipfs/interface-go-ipfs-core#CoreAPI
3534
type HttpApi struct {
3635
url string
37-
httpcli gohttp.Client
36+
httpcli http.Client
3837
Headers http.Header
3938
applyGlobal func(*requestBuilder)
4039
}
@@ -85,9 +84,9 @@ func ApiAddr(ipfspath string) (ma.Multiaddr, error) {
8584

8685
// NewApi constructs HttpApi with specified endpoint
8786
func NewApi(a ma.Multiaddr) (*HttpApi, error) {
88-
c := &gohttp.Client{
89-
Transport: &gohttp.Transport{
90-
Proxy: gohttp.ProxyFromEnvironment,
87+
c := &http.Client{
88+
Transport: &http.Transport{
89+
Proxy: http.ProxyFromEnvironment,
9190
DisableKeepAlives: true,
9291
},
9392
}
@@ -96,7 +95,7 @@ func NewApi(a ma.Multiaddr) (*HttpApi, error) {
9695
}
9796

9897
// NewApiWithClient constructs HttpApi with specified endpoint and custom http client
99-
func NewApiWithClient(a ma.Multiaddr, c *gohttp.Client) (*HttpApi, error) {
98+
func NewApiWithClient(a ma.Multiaddr, c *http.Client) (*HttpApi, error) {
10099
_, url, err := manet.DialArgs(a)
101100
if err != nil {
102101
return nil, err
@@ -112,7 +111,7 @@ func NewApiWithClient(a ma.Multiaddr, c *gohttp.Client) (*HttpApi, error) {
112111
return NewURLApiWithClient(url, c)
113112
}
114113

115-
func NewURLApiWithClient(url string, c *gohttp.Client) (*HttpApi, error) {
114+
func NewURLApiWithClient(url string, c *http.Client) (*HttpApi, error) {
116115
api := &HttpApi{
117116
url: url,
118117
httpcli: *c,
@@ -121,7 +120,7 @@ func NewURLApiWithClient(url string, c *gohttp.Client) (*HttpApi, error) {
121120
}
122121

123122
// We don't support redirects.
124-
api.httpcli.CheckRedirect = func(_ *gohttp.Request, _ []*gohttp.Request) error {
123+
api.httpcli.CheckRedirect = func(_ *http.Request, _ []*http.Request) error {
125124
return fmt.Errorf("unexpected redirect")
126125
}
127126
return api, nil

api_test.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"io/ioutil"
66
"net/http"
7-
gohttp "net/http"
87
"net/http/httptest"
98
"os"
109
"strconv"
@@ -163,9 +162,9 @@ func (NodeProvider) makeAPISwarm(ctx context.Context, fullIdentity bool, n int)
163162
return
164163
}
165164

166-
c := &gohttp.Client{
167-
Transport: &gohttp.Transport{
168-
Proxy: gohttp.ProxyFromEnvironment,
165+
c := &http.Client{
166+
Transport: &http.Transport{
167+
Proxy: http.ProxyFromEnvironment,
169168
DisableKeepAlives: true,
170169
DisableCompression: true,
171170
},

object.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/ipfs/go-cid"
1111
ipld "github.com/ipfs/go-ipld-format"
1212
"github.com/ipfs/go-merkledag"
13-
dag "github.com/ipfs/go-merkledag"
1413
ft "github.com/ipfs/go-unixfs"
1514
"github.com/ipfs/interface-go-ipfs-core"
1615
caopts "github.com/ipfs/interface-go-ipfs-core/options"
@@ -32,7 +31,7 @@ func (api *ObjectAPI) New(ctx context.Context, opts ...caopts.ObjectNewOption) (
3231
var n ipld.Node
3332
switch options.Type {
3433
case "empty":
35-
n = new(dag.ProtoNode)
34+
n = new(merkledag.ProtoNode)
3635
case "unixfs-dir":
3736
n = ft.EmptyDirNode()
3837
default:

pin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (api *PinAPI) IsPinned(ctx context.Context, p path.Path, opts ...caopts.Pin
9393
if err != nil {
9494
// TODO: This error-type discrimination based on sub-string matching is brittle.
9595
// It is addressed by this open issue: https://github.com/ipfs/go-ipfs/issues/7563
96-
if strings.Index(err.Error(), "is not pinned") != -1 {
96+
if strings.Contains(err.Error(), "is not pinned") {
9797
return "", false, nil
9898
}
9999
return "", false, err

0 commit comments

Comments
 (0)