@cryptotaxi247 / kubo / commits / e550d9e47

ci: add stylecheck to golangci-lint (#9334)

Gus Eggert committed Oct 6, 2022 at 10:18 UTC e550d9e4761ea394357c413c02ade142c0dea88c
51 files changed +171 -173
.golangci.yml new
+3
@@ -0,0 +1,3 @@
1 +linters:
2 + enable:
3 + - stylecheck
cmd/ipfs/add_migrations.go
+3 -3
@@ -56,7 +56,7 @@ func addMigrations(ctx context.Context, node *core.IpfsNode, fetcher migrations.
56 }
57 }
58 default:
59 - return errors.New("Cannot get migrations from unknown fetcher type")
59 + return errors.New("cannot get migrations from unknown fetcher type")
60 }
61 }
62
@@ -118,9 +118,9 @@ func addMigrationPaths(ctx context.Context, node *core.IpfsNode, peerInfo peer.A
118 fmt.Printf("connected to migration peer %q\n", peerInfo)
119
120 if pin {
121 - pinApi := ipfs.Pin()
121 + pinAPI := ipfs.Pin()
122 for _, ipfsPath := range paths {
123 - err := pinApi.Add(ctx, ipfsPath)
123 + err := pinAPI.Add(ctx, ipfsPath)
124 if err != nil {
125 return err
126 }
cmd/ipfs/daemon.go
+3 -3
@@ -62,7 +62,7 @@ const (
62 routingOptionCustomKwd = "custom"
63 routingOptionDefaultKwd = "default"
64 unencryptTransportKwd = "disable-transport-encryption"
65 - unrestrictedApiAccessKwd = "unrestricted-api"
65 + unrestrictedAPIAccessKwd = "unrestricted-api"
66 writableKwd = "writable"
67 enablePubSubKwd = "enable-pubsub-experiment"
68 enableIPNSPubSubKwd = "enable-namesys-pubsub"
@@ -174,7 +174,7 @@ Headers.
174 cmds.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)"),
175 cmds.StringOption(ipfsMountKwd, "Path to the mountpoint for IPFS (if using --mount). Defaults to config setting."),
176 cmds.StringOption(ipnsMountKwd, "Path to the mountpoint for IPNS (if using --mount). Defaults to config setting."),
177 - cmds.BoolOption(unrestrictedApiAccessKwd, "Allow API access to unlisted hashes"),
177 + cmds.BoolOption(unrestrictedAPIAccessKwd, "Allow API access to unlisted hashes"),
178 cmds.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)"),
179 cmds.BoolOption(enableGCKwd, "Enable automatic periodic repo garbage collection"),
180 cmds.BoolOption(adjustFDLimitKwd, "Check and raise file descriptor limits if needed").WithDefault(true),
@@ -654,7 +654,7 @@ func serveHTTPApi(req *cmds.Request, cctx *oldcmds.Context) (<-chan error, error
654 // because this would open up the api to scripting vulnerabilities.
655 // only the webui objects are allowed.
656 // if you know what you're doing, go ahead and pass --unrestricted-api.
657 - unrestricted, _ := req.Options[unrestrictedApiAccessKwd].(bool)
657 + unrestricted, _ := req.Options[unrestrictedAPIAccessKwd].(bool)
658 gatewayOpt := corehttp.GatewayOption(false, corehttp.WebUIPaths...)
659 if unrestricted {
660 gatewayOpt = corehttp.GatewayOption(true, "/ipfs", "/ipns")
cmd/ipfs/init.go
+2 -1
@@ -32,8 +32,9 @@ const (
32 profileOptionName = "profile"
33 )
34
35 +// nolint
36 var errRepoExists = errors.New(`ipfs configuration file already exists!
36 -Reinitializing would overwrite your keys.
37 +Reinitializing would overwrite your keys
38 `)
39
40 var initCmd = &cmds.Command{
cmd/ipfs/ipfs.go
+1 -1
@@ -6,7 +6,7 @@ import (
6 cmds "github.com/ipfs/go-ipfs-cmds"
7 )
8
9 -// This is the CLI root, used for executing commands accessible to CLI clients.
9 +// Root is the CLI root, used for executing commands accessible to CLI clients.
10 // Some subcommands (like 'ipfs daemon' or 'ipfs init') are only accessible here,
11 // and can't be called through the HTTP API.
12 var Root = &cmds.Command{
cmd/ipfs/pinmfs_test.go
+6 -6
@@ -98,7 +98,7 @@ func TestPinMFSRootNodeError(t *testing.T) {
98 }
99
100 func TestPinMFSService(t *testing.T) {
101 - cfg_invalid_interval := &config.Config{
101 + cfgInvalidInterval := &config.Config{
102 Pinning: config.Pinning{
103 RemoteServices: map[string]config.RemotePinningService{
104 "disabled": {
@@ -119,7 +119,7 @@ func TestPinMFSService(t *testing.T) {
119 },
120 },
121 }
122 - cfg_valid_unnamed := &config.Config{
122 + cfgValidUnnamed := &config.Config{
123 Pinning: config.Pinning{
124 RemoteServices: map[string]config.RemotePinningService{
125 "valid_unnamed": {
@@ -134,7 +134,7 @@ func TestPinMFSService(t *testing.T) {
134 },
135 },
136 }
137 - cfg_valid_named := &config.Config{
137 + cfgValidNamed := &config.Config{
138 Pinning: config.Pinning{
139 RemoteServices: map[string]config.RemotePinningService{
140 "valid_named": {
@@ -149,9 +149,9 @@ func TestPinMFSService(t *testing.T) {
149 },
150 },
151 }
152 - testPinMFSServiceWithError(t, cfg_invalid_interval, "remote pinning service \"invalid_interval\" has invalid MFS.RepinInterval")
153 - testPinMFSServiceWithError(t, cfg_valid_unnamed, "error while listing remote pins: empty response from remote pinning service")
154 - testPinMFSServiceWithError(t, cfg_valid_named, "error while listing remote pins: empty response from remote pinning service")
152 + testPinMFSServiceWithError(t, cfgInvalidInterval, "remote pinning service \"invalid_interval\" has invalid MFS.RepinInterval")
153 + testPinMFSServiceWithError(t, cfgValidUnnamed, "error while listing remote pins: empty response from remote pinning service")
154 + testPinMFSServiceWithError(t, cfgValidNamed, "error while listing remote pins: empty response from remote pinning service")
155 }
156
157 func testPinMFSServiceWithError(t *testing.T, cfg *config.Config, expectedErrorPrefix string) {
config/experiments.go
+1 -1
@@ -6,7 +6,7 @@ type Experiments struct {
6 ShardingEnabled bool `json:",omitempty"` // deprecated by autosharding: https://github.com/ipfs/kubo/pull/8527
7 GraphsyncEnabled bool
8 Libp2pStreamMounting bool
9 - P2pHttpProxy bool
9 + P2pHttpProxy bool //nolint
10 StrategicProviding bool
11 AcceleratedDHTClient bool
12 }
core/commands/cid.go
+1 -2
@@ -13,7 +13,6 @@ import (
13 verifcid "github.com/ipfs/go-verifcid"
14 ipldmulticodec "github.com/ipld/go-ipld-prime/multicodec"
15 mbase "github.com/multiformats/go-multibase"
16 - "github.com/multiformats/go-multicodec"
16 mc "github.com/multiformats/go-multicodec"
17 mhash "github.com/multiformats/go-multihash"
18 )
@@ -71,7 +70,7 @@ The optional format string is a printf style format string:
70 opts.fmtStr = fmtStr
71
72 if codecStr != "" {
74 - var codec multicodec.Code
73 + var codec mc.Code
74 err := codec.Set(codecStr)
75 if err != nil {
76 return err
core/commands/cmdenv/env.go
+1 -1
@@ -27,7 +27,7 @@ func GetNode(env interface{}) (*core.IpfsNode, error) {
27 }
28
29 // GetApi extracts CoreAPI instance from the environment.
30 -func GetApi(env cmds.Environment, req *cmds.Request) (coreiface.CoreAPI, error) {
30 +func GetApi(env cmds.Environment, req *cmds.Request) (coreiface.CoreAPI, error) { //nolint
31 ctx, ok := env.(*commands.Context)
32 if !ok {
33 return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env)
core/commands/dag/dag.go
+2 -2
@@ -223,7 +223,7 @@ Specification of CAR formats: https://ipld.io/specs/transport/car/
223 // event should have only one of `Root` or `Stats` set, not both
224 if event.Root == nil {
225 if event.Stats == nil {
226 - return fmt.Errorf("Unexpected message from DAG import")
226 + return fmt.Errorf("unexpected message from DAG import")
227 }
228 stats, _ := req.Options[statsOptionName].(bool)
229 if stats {
@@ -233,7 +233,7 @@ Specification of CAR formats: https://ipld.io/specs/transport/car/
233 }
234
235 if event.Stats != nil {
236 - return fmt.Errorf("Unexpected message from DAG import")
236 + return fmt.Errorf("unexpected message from DAG import")
237 }
238
239 enc, err := cmdenv.GetLowLevelCidEncoder(req)
core/commands/dag/export.go
+1 -1
@@ -85,7 +85,7 @@ func finishCLIExport(res cmds.Response, re cmds.ResponseEmitter) error {
85 if !specified {
86 // default based on TTY availability
87 errStat, _ := os.Stderr.Stat()
88 - if 0 != (errStat.Mode() & os.ModeCharDevice) {
88 + if (errStat.Mode() & os.ModeCharDevice) != 0 {
89 showProgress = true
90 }
91 } else if val.(bool) {
core/commands/id.go
+4 -4
@@ -23,9 +23,9 @@ import (
23 identify "github.com/libp2p/go-libp2p/p2p/protocol/identify"
24 )
25
26 -const offlineIdErrorMessage = "'ipfs id' cannot query information on remote peers without a running daemon; if you only want to convert --peerid-base, pass --offline option."
26 +const offlineIDErrorMessage = "'ipfs id' cannot query information on remote peers without a running daemon; if you only want to convert --peerid-base, pass --offline option"
27
28 -type IdOutput struct {
28 +type IdOutput struct { //nolint
29 ID string
30 PublicKey string
31 Addresses []string
@@ -98,7 +98,7 @@ EXAMPLE:
98
99 offline, _ := req.Options[OfflineOption].(bool)
100 if !offline && !n.IsOnline {
101 - return errors.New(offlineIdErrorMessage)
101 + return errors.New(offlineIDErrorMessage)
102 }
103
104 if !offline {
@@ -107,7 +107,7 @@ EXAMPLE:
107 switch err {
108 case nil:
109 case kb.ErrLookupFailure:
110 - return errors.New(offlineIdErrorMessage)
110 + return errors.New(offlineIDErrorMessage)
111 default:
112 return err
113 }
core/commands/keystore.go
+2 -2
@@ -56,7 +56,7 @@ publish'.
56
57 type KeyOutput struct {
58 Name string
59 - Id string
59 + Id string //nolint
60 }
61
62 type KeyOutputList struct {
@@ -67,7 +67,7 @@ type KeyOutputList struct {
67 type KeyRenameOutput struct {
68 Was string
69 Now string
70 - Id string
70 + Id string //nolint
71 Overwrite bool
72 }
73
core/commands/multibase.go
+4 -4
@@ -105,11 +105,11 @@ This command expects multibase inside of a file or via stdin:
105 if err != nil {
106 return fmt.Errorf("failed to access file: %w", err)
107 }
108 - encoded_data, err := io.ReadAll(file)
108 + encodedData, err := io.ReadAll(file)
109 if err != nil {
110 return fmt.Errorf("failed to read file contents: %w", err)
111 }
112 - _, data, err := mbase.Decode(string(encoded_data))
112 + _, data, err := mbase.Decode(string(encodedData))
113 if err != nil {
114 return fmt.Errorf("failed to decode multibase: %w", err)
115 }
@@ -156,11 +156,11 @@ but one can customize used base with -b:
156 if err != nil {
157 return fmt.Errorf("failed to access file: %w", err)
158 }
159 - encoded_data, err := io.ReadAll(file)
159 + encodedData, err := io.ReadAll(file)
160 if err != nil {
161 return fmt.Errorf("failed to read file contents: %w", err)
162 }
163 - _, data, err := mbase.Decode(string(encoded_data))
163 + _, data, err := mbase.Decode(string(encodedData))
164 if err != nil {
165 return fmt.Errorf("failed to decode multibase: %w", err)
166 }
core/commands/pin/remotepin.go
+9 -9
@@ -214,27 +214,27 @@ NOTE: a comma-separated notation is supported in CLI for convenience:
214
215 // Block unless --background=true is passed
216 if !req.Options[pinBackgroundOptionName].(bool) {
217 - requestId := ps.GetRequestId()
217 + requestID := ps.GetRequestId()
218 for {
219 - ps, err = c.GetStatusByID(ctx, requestId)
219 + ps, err = c.GetStatusByID(ctx, requestID)
220 if err != nil {
221 - return fmt.Errorf("failed to check pin status for requestid=%q due to error: %v", requestId, err)
221 + return fmt.Errorf("failed to check pin status for requestid=%q due to error: %v", requestID, err)
222 }
223 - if ps.GetRequestId() != requestId {
224 - return fmt.Errorf("failed to check pin status for requestid=%q, remote service sent unexpected requestid=%q", requestId, ps.GetRequestId())
223 + if ps.GetRequestId() != requestID {
224 + return fmt.Errorf("failed to check pin status for requestid=%q, remote service sent unexpected requestid=%q", requestID, ps.GetRequestId())
225 }
226 s := ps.GetStatus()
227 if s == pinclient.StatusPinned {
228 break
229 }
230 if s == pinclient.StatusFailed {
231 - return fmt.Errorf("remote service failed to pin requestid=%q", requestId)
231 + return fmt.Errorf("remote service failed to pin requestid=%q", requestID)
232 }
233 tmr := time.NewTimer(time.Second / 2)
234 select {
235 case <-tmr.C:
236 case <-ctx.Done():
237 - return fmt.Errorf("waiting for pin interrupted, requestid=%q remains on remote service", requestId)
237 + return fmt.Errorf("waiting for pin interrupted, requestid=%q remains on remote service", requestID)
238 }
239 }
240 }
@@ -665,8 +665,8 @@ TIP: pass '--enc=json' for more useful JSON output.
665
666 type ServiceDetails struct {
667 Service string
668 - ApiEndpoint string
669 - Stat *Stat `json:",omitempty"` // present only when --stat not passed
668 + ApiEndpoint string //nolint
669 + Stat *Stat `json:",omitempty"` // present only when --stat not passed
670 }
671
672 type Stat struct {
core/commands/root.go
+1 -2
@@ -25,7 +25,7 @@ const (
25 DebugOption = "debug"
26 LocalOption = "local" // DEPRECATED: use OfflineOption
27 OfflineOption = "offline"
28 - ApiOption = "api"
28 + ApiOption = "api" //nolint
29 )
30
31 var Root = &cmds.Command{
@@ -118,7 +118,6 @@ The CLI will exit with one of the following values:
118 },
119 }
120
121 -// commandsDaemonCmd is the "ipfs commands" command for daemon
121 var CommandsDaemonCmd = CommandsCmd(Root)
122
123 var rootSubcommands = map[string]*cmds.Command{
core/commands/stat.go
+2 -2
@@ -132,8 +132,8 @@ Example:
132 return err
133 }
134 } else if tfound {
135 - protoId := protocol.ID(tstr)
136 - stats := nd.Reporter.GetBandwidthForProtocol(protoId)
135 + protoID := protocol.ID(tstr)
136 + stats := nd.Reporter.GetBandwidthForProtocol(protoID)
137 if err := res.Emit(&stats); err != nil {
138 return err
139 }
core/commands/swarm.go
+2 -2
@@ -336,7 +336,7 @@ The output of this command is JSON.
336 }
337
338 if node.ResourceManager == nil {
339 - return libp2p.NoResourceMgrError
339 + return libp2p.ErrNoResourceMgr
340 }
341
342 if len(req.Arguments) != 1 {
@@ -394,7 +394,7 @@ Changes made via command line are persisted in the Swarm.ResourceMgr.Limits fiel
394 }
395
396 if node.ResourceManager == nil {
397 - return libp2p.NoResourceMgrError
397 + return libp2p.ErrNoResourceMgr
398 }
399
400 scope := req.Arguments[0]
core/core_test.go
+14 -14
@@ -85,18 +85,18 @@ var errNotSupported = errors.New("method not supported")
85 func TestDelegatedRoutingSingle(t *testing.T) {
86 require := require.New(t)
87
88 - pId1, priv1, err := GeneratePeerID()
88 + pID1, priv1, err := GeneratePeerID()
89 require.NoError(err)
90
91 - pId2, _, err := GeneratePeerID()
91 + pID2, _, err := GeneratePeerID()
92 require.NoError(err)
93
94 - theID := path.Join("/ipns", string(pId1))
95 - theErrorID := path.Join("/ipns", string(pId2))
94 + theID := path.Join("/ipns", string(pID1))
95 + theErrorID := path.Join("/ipns", string(pID2))
96
97 d := &delegatedRoutingService{
98 - goodPeerID: pId1,
99 - badPeerID: pId2,
98 + goodPeerID: pID1,
99 + badPeerID: pID2,
100 pk1: priv1,
101 }
102
@@ -122,18 +122,18 @@ func TestDelegatedRoutingSingle(t *testing.T) {
122 func TestDelegatedRoutingMulti(t *testing.T) {
123 require := require.New(t)
124
125 - pId1, priv1, err := GeneratePeerID()
125 + pID1, priv1, err := GeneratePeerID()
126 require.NoError(err)
127
128 - pId2, priv2, err := GeneratePeerID()
128 + pID2, priv2, err := GeneratePeerID()
129 require.NoError(err)
130
131 - theID1 := path.Join("/ipns", string(pId1))
132 - theID2 := path.Join("/ipns", string(pId2))
131 + theID1 := path.Join("/ipns", string(pID1))
132 + theID2 := path.Join("/ipns", string(pID2))
133
134 d1 := &delegatedRoutingService{
135 - goodPeerID: pId1,
136 - badPeerID: pId2,
135 + goodPeerID: pID1,
136 + badPeerID: pID2,
137 pk1: priv1,
138 serviceID: 1,
139 }
@@ -141,8 +141,8 @@ func TestDelegatedRoutingMulti(t *testing.T) {
141 url1 := StartRoutingServer(t, d1)
142
143 d2 := &delegatedRoutingService{
144 - goodPeerID: pId2,
145 - badPeerID: pId1,
144 + goodPeerID: pID2,
145 + badPeerID: pID1,
146 pk1: priv2,
147 serviceID: 2,
148 }
core/coreapi/coreapi.go
+18 -18
@@ -158,7 +158,7 @@ func (api *CoreAPI) WithOptions(opts ...options.ApiOption) (coreiface.CoreAPI, e
158
159 n := api.nd
160
161 - subApi := &CoreAPI{
161 + subAPI := &CoreAPI{
162 nctx: n.Context(),
163
164 identity: n.Identity,
@@ -190,14 +190,14 @@ func (api *CoreAPI) WithOptions(opts ...options.ApiOption) (coreiface.CoreAPI, e
190 parentOpts: settings,
191 }
192
193 - subApi.checkOnline = func(allowOffline bool) error {
193 + subAPI.checkOnline = func(allowOffline bool) error {
194 if !n.IsOnline && !allowOffline {
195 return coreiface.ErrOffline
196 }
197 return nil
198 }
199
200 - subApi.checkPublishAllowed = func() error {
200 + subAPI.checkPublishAllowed = func() error {
201 if n.Mounts.Ipns != nil && n.Mounts.Ipns.IsActive() {
202 return errors.New("cannot manually publish while IPNS is mounted")
203 }
@@ -218,39 +218,39 @@ func (api *CoreAPI) WithOptions(opts ...options.ApiOption) (coreiface.CoreAPI, e
218 return nil, fmt.Errorf("cannot specify negative resolve cache size")
219 }
220
221 - subApi.routing = offlineroute.NewOfflineRouter(subApi.repo.Datastore(), subApi.recordValidator)
221 + subAPI.routing = offlineroute.NewOfflineRouter(subAPI.repo.Datastore(), subAPI.recordValidator)
222
223 - subApi.namesys, err = namesys.NewNameSystem(subApi.routing,
224 - namesys.WithDatastore(subApi.repo.Datastore()),
225 - namesys.WithDNSResolver(subApi.dnsResolver),
223 + subAPI.namesys, err = namesys.NewNameSystem(subAPI.routing,
224 + namesys.WithDatastore(subAPI.repo.Datastore()),
225 + namesys.WithDNSResolver(subAPI.dnsResolver),
226 namesys.WithCache(cs))
227 if err != nil {
228 return nil, fmt.Errorf("error constructing namesys: %w", err)
229 }
230
231 - subApi.provider = provider.NewOfflineProvider()
231 + subAPI.provider = provider.NewOfflineProvider()
232
233 - subApi.peerstore = nil
234 - subApi.peerHost = nil
235 - subApi.recordValidator = nil
233 + subAPI.peerstore = nil
234 + subAPI.peerHost = nil
235 + subAPI.recordValidator = nil
236 }
237
238 if settings.Offline || !settings.FetchBlocks {
239 - subApi.exchange = offlinexch.Exchange(subApi.blockstore)
240 - subApi.blocks = bserv.New(subApi.blockstore, subApi.exchange)
241 - subApi.dag = dag.NewDAGService(subApi.blocks)
239 + subAPI.exchange = offlinexch.Exchange(subAPI.blockstore)
240 + subAPI.blocks = bserv.New(subAPI.blockstore, subAPI.exchange)
241 + subAPI.dag = dag.NewDAGService(subAPI.blocks)
242 }
243
244 - return subApi, nil
244 + return subAPI, nil
245 }
246
247 // getSession returns new api backed by the same node with a read-only session DAG
248 func (api *CoreAPI) getSession(ctx context.Context) *CoreAPI {
249 - sesApi := *api
249 + sesAPI := *api
250
251 // TODO: We could also apply this to api.blocks, and compose into writable api,
252 // but this requires some changes in blockservice/merkledag
253 - sesApi.dag = dag.NewReadOnlyDagService(dag.NewSession(ctx, api.dag))
253 + sesAPI.dag = dag.NewReadOnlyDagService(dag.NewSession(ctx, api.dag))
254
255 - return &sesApi
255 + return &sesAPI
256 }
core/coreapi/pubsub.go
+1 -1
@@ -97,7 +97,7 @@ func (api *PubSubAPI) Subscribe(ctx context.Context, topic string, opts ...caopt
97
98 func (api *PubSubAPI) checkNode() (routing.Routing, error) {
99 if api.pubSub == nil {
100 - return nil, errors.New("experimental pubsub feature not enabled. Run daemon with --enable-pubsub-experiment to use.")
100 + return nil, errors.New("experimental pubsub feature not enabled, run daemon with --enable-pubsub-experiment to use")
101 }
102
103 err := api.checkOnline(false)
core/coreapi/unixfs.go
+1 -2
@@ -19,7 +19,6 @@ import (
19 bstore "github.com/ipfs/go-ipfs-blockstore"
20 files "github.com/ipfs/go-ipfs-files"
21 ipld "github.com/ipfs/go-ipld-format"
22 - dag "github.com/ipfs/go-merkledag"
22 merkledag "github.com/ipfs/go-merkledag"
23 dagtest "github.com/ipfs/go-merkledag/test"
24 mfs "github.com/ipfs/go-mfs"
@@ -117,7 +116,7 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options
116 }
117
118 bserv := blockservice.New(addblockstore, exch) // hash security 001
120 - dserv := dag.NewDAGService(bserv)
119 + dserv := merkledag.NewDAGService(bserv)
120
121 // add a sync call to the DagService
122 // this ensures that data written to the DagService is persisted to the underlying datastore
core/corehttp/gateway.go
+2 -2
@@ -77,7 +77,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption {
77
78 AddAccessControlHeaders(headers)
79
80 - offlineApi, err := api.WithOptions(options.Api.Offline(true))
80 + offlineAPI, err := api.WithOptions(options.Api.Offline(true))
81 if err != nil {
82 return nil, err
83 }
@@ -86,7 +86,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption {
86 Headers: headers,
87 Writable: writable,
88 FastDirIndexThreshold: int(cfg.Gateway.FastDirIndexThreshold.WithDefault(100)),
89 - }, api, offlineApi)
89 + }, api, offlineAPI)
90
91 gateway = otelhttp.NewHandler(gateway, "Gateway.Request")
92
core/corehttp/gateway_handler.go
+8 -8
@@ -39,7 +39,7 @@ const (
39 )
40
41 var (
42 - onlyAscii = regexp.MustCompile("[[:^ascii:]]")
42 + onlyASCII = regexp.MustCompile("[[:^ascii:]]")
43 noModtime = time.Unix(0, 0) // disables Last-Modified header if passed as modtime
44 )
45
@@ -68,7 +68,7 @@ type redirectTemplateData struct {
68 type gatewayHandler struct {
69 config GatewayConfig
70 api NodeAPI
71 - offlineApi NodeAPI
71 + offlineAPI NodeAPI
72
73 // generic metrics
74 firstContentBlockGetMetric *prometheus.HistogramVec
@@ -214,15 +214,15 @@ func newGatewayHistogramMetric(name string, help string) *prometheus.HistogramVe
214
215 // NewGatewayHandler returns an http.Handler that can act as a gateway to IPFS content
216 // offlineApi is a version of the API that should not make network requests for missing data
217 -func NewGatewayHandler(c GatewayConfig, api NodeAPI, offlineApi NodeAPI) http.Handler {
218 - return newGatewayHandler(c, api, offlineApi)
217 +func NewGatewayHandler(c GatewayConfig, api NodeAPI, offlineAPI NodeAPI) http.Handler {
218 + return newGatewayHandler(c, api, offlineAPI)
219 }
220
221 -func newGatewayHandler(c GatewayConfig, api NodeAPI, offlineApi NodeAPI) *gatewayHandler {
221 +func newGatewayHandler(c GatewayConfig, api NodeAPI, offlineAPI NodeAPI) *gatewayHandler {
222 i := &gatewayHandler{
223 config: c,
224 api: api,
225 - offlineApi: offlineApi,
225 + offlineAPI: offlineAPI,
226 // Improved Metrics
227 // ----------------------------
228 // Time till the first content block (bar in /ipfs/cid/foo/bar)
@@ -683,7 +683,7 @@ func addContentDispositionHeader(w http.ResponseWriter, r *http.Request, content
683 // Set Content-Disposition to arbitrary filename and disposition
684 func setContentDispositionHeader(w http.ResponseWriter, filename string, disposition string) {
685 utf8Name := url.PathEscape(filename)
686 - asciiName := url.PathEscape(onlyAscii.ReplaceAllLiteralString(filename, "_"))
686 + asciiName := url.PathEscape(onlyASCII.ReplaceAllLiteralString(filename, "_"))
687 w.Header().Set("Content-Disposition", fmt.Sprintf("%s; filename=\"%s\"; filename*=UTF-8''%s", disposition, asciiName, utf8Name))
688 }
689
@@ -933,7 +933,7 @@ func (i *gatewayHandler) handlePathResolution(w http.ResponseWriter, r *http.Req
933 // https://github.com/ipfs/specs/blob/main/http-gateways/PATH_GATEWAY.md#cache-control-request-header
934 func (i *gatewayHandler) handleOnlyIfCached(w http.ResponseWriter, r *http.Request, contentPath ipath.Path, logger *zap.SugaredLogger) (requestHandled bool) {
935 if r.Header.Get("Cache-Control") == "only-if-cached" {
936 - _, err := i.offlineApi.Block().Stat(r.Context(), contentPath)
936 + _, err := i.offlineAPI.Block().Stat(r.Context(), contentPath)
937 if err != nil {
938 if r.Method == http.MethodHead {
939 w.WriteHeader(http.StatusPreconditionFailed)
core/corehttp/gateway_handler_unixfs_dir.go
+5 -5
@@ -39,10 +39,10 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit
39 webError(w, "failed to parse request path", err, http.StatusInternalServerError)
40 return
41 }
42 - originalUrlPath := requestURI.Path
42 + originalURLPath := requestURI.Path
43
44 // Ensure directory paths end with '/'
45 - if originalUrlPath[len(originalUrlPath)-1] != '/' {
45 + if originalURLPath[len(originalURLPath)-1] != '/' {
46 // don't redirect to trailing slash if it's go get
47 // https://github.com/ipfs/kubo/pull/3963
48 goget := r.URL.Query().Get("go-get") == "1"
@@ -53,7 +53,7 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit
53 suffix = suffix + "?" + r.URL.RawQuery
54 }
55 // /ipfs/cid/foo?bar must be redirected to /ipfs/cid/foo/?bar
56 - redirectURL := originalUrlPath + suffix
56 + redirectURL := originalURLPath + suffix
57 logger.Debugw("directory location moved permanently", "status", http.StatusMovedPermanently)
58 http.Redirect(w, r, redirectURL, http.StatusMovedPermanently)
59 return
@@ -125,7 +125,7 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit
125 di := directoryItem{
126 Size: "", // no size because we did not fetch child nodes
127 Name: link.Name,
128 - Path: gopath.Join(originalUrlPath, link.Name),
128 + Path: gopath.Join(originalURLPath, link.Name),
129 Hash: hash,
130 ShortHash: shortHash(hash),
131 }
@@ -149,7 +149,7 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit
149
150 // construct the correct back link
151 // https://github.com/ipfs/kubo/issues/1365
152 - var backLink string = originalUrlPath
152 + backLink := originalURLPath
153
154 // don't go further up than /ipfs/$hash/
155 pathSplit := path.SplitList(contentPath.String())
core/corehttp/gateway_indexPage.go
+2 -2
@@ -117,8 +117,8 @@ func init() {
117
118 // custom template-escaping function to escape a full path, including '#' and '?'
119 urlEscape := func(rawUrl string) string {
120 - pathUrl := url.URL{Path: rawUrl}
121 - return pathUrl.String()
120 + pathURL := url.URL{Path: rawUrl}
121 + return pathURL.String()
122 }
123
124 // Directory listing template
core/corehttp/lazyseek_test.go
+3 -3
@@ -11,14 +11,14 @@ type badSeeker struct {
11 io.ReadSeeker
12 }
13
14 -var badSeekErr = fmt.Errorf("I'm a bad seeker")
14 +var errBadSeek = fmt.Errorf("bad seeker")
15
16 func (bs badSeeker) Seek(offset int64, whence int) (int64, error) {
17 off, err := bs.ReadSeeker.Seek(0, io.SeekCurrent)
18 if err != nil {
19 panic(err)
20 }
21 - return off, badSeekErr
21 + return off, errBadSeek
22 }
23
24 func TestLazySeekerError(t *testing.T) {
@@ -73,7 +73,7 @@ func TestLazySeekerError(t *testing.T) {
73 if err == nil {
74 t.Fatalf("expected an error, got output %s", string(b))
75 }
76 - if err != badSeekErr {
76 + if err != errBadSeek {
77 t.Fatalf("expected a bad seek error, got %s", err)
78 }
79 if len(b) != 0 {
core/corehttp/metrics.go
+1 -1
@@ -164,7 +164,7 @@ type IpfsNodeCollector struct {
164 Node *core.IpfsNode
165 }
166
167 -func (_ IpfsNodeCollector) Describe(ch chan<- *prometheus.Desc) {
167 +func (IpfsNodeCollector) Describe(ch chan<- *prometheus.Desc) {
168 ch <- peersTotalMetric
169 }
170
core/corehttp/p2p_proxy.go
+3 -3
@@ -58,11 +58,11 @@ func parseRequest(request *http.Request) (*proxyRequest, error) {
58
59 split := strings.SplitN(path, "/", 5)
60 if len(split) < 5 {
61 - return nil, fmt.Errorf("Invalid request path '%s'", path)
61 + return nil, fmt.Errorf("invalid request path '%s'", path)
62 }
63
64 if _, err := peer.Decode(split[2]); err != nil {
65 - return nil, fmt.Errorf("Invalid request path '%s'", path)
65 + return nil, fmt.Errorf("invalid request path '%s'", path)
66 }
67
68 if split[3] == "http" {
@@ -71,7 +71,7 @@ func parseRequest(request *http.Request) (*proxyRequest, error) {
71
72 split = strings.SplitN(path, "/", 7)
73 if len(split) < 7 || split[3] != "x" || split[5] != "http" {
74 - return nil, fmt.Errorf("Invalid request path '%s'", path)
74 + return nil, fmt.Errorf("invalid request path '%s'", path)
75 }
76
77 return &proxyRequest{split[2], protocol.ID("/x/" + split[4] + "/http"), split[6]}, nil
core/corehttp/redirect.go
+1 -1
@@ -24,5 +24,5 @@ type redirectHandler struct {
24 }
25
26 func (i *redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
27 - http.Redirect(w, r, i.path, 302)
27 + http.Redirect(w, r, i.path, http.StatusFound)
28 }
core/corehttp/webui.go
+1 -1
@@ -3,7 +3,7 @@ package corehttp
3 // TODO: move to IPNS
4 const WebUIPath = "/ipfs/bafybeiageaoxg6d7npaof6eyzqbwvbubyler7bq44hayik2hvqcggg7d2y" // v2.18.1
5
6 -// this is a list of all past webUI paths.
6 +// WebUIPaths is a list of all past webUI paths.
7 var WebUIPaths = []string{
8 WebUIPath,
9 "/ipfs/bafybeidb5eryh72zajiokdggzo7yct2d6hhcflncji5im2y5w26uuygdsm",
core/node/libp2p/libp2p.go
-1
@@ -25,7 +25,6 @@ type Libp2pOpts struct {
25 Opts []libp2p.Option `group:"libp2p"`
26 }
27
28 -// Misc options
28 var UserAgent = simpleOpt(libp2p.UserAgent(version.GetUserAgentVersion()))
29
30 func ConnectionManager(low, high int, grace time.Duration) func() (opts Libp2pOpts, err error) {
core/node/libp2p/rcmgr.go
+4 -4
@@ -28,7 +28,7 @@ import (
28 const NetLimitDefaultFilename = "limit.json"
29 const NetLimitTraceFilename = "rcmgr.json.gz"
30
31 -var NoResourceMgrError = fmt.Errorf("missing ResourceMgr: make sure the daemon is running with Swarm.ResourceMgr.Enabled")
31 +var ErrNoResourceMgr = fmt.Errorf("missing ResourceMgr: make sure the daemon is running with Swarm.ResourceMgr.Enabled")
32
33 func ResourceManager(cfg config.SwarmConfig) interface{} {
34 return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, repo repo.Repo) (network.ResourceManager, Libp2pOpts, error) {
@@ -136,7 +136,7 @@ func NetStat(mgr network.ResourceManager, scope string) (NetStatOut, error) {
136 case scope == "all":
137 rapi, ok := mgr.(rcmgr.ResourceManagerState)
138 if !ok { // NullResourceManager
139 - return result, NoResourceMgrError
139 + return result, ErrNoResourceMgr
140 }
141
142 stat := rapi.Stat()
@@ -223,7 +223,7 @@ func NetLimit(mgr network.ResourceManager, scope string) (rcmgr.BaseLimit, error
223 getLimit := func(s network.ResourceScope) error {
224 limiter, ok := s.(rcmgr.ResourceScopeLimiter)
225 if !ok { // NullResourceManager
226 - return NoResourceMgrError
226 + return ErrNoResourceMgr
227 }
228 limit := limiter.Limit()
229 switch l := limit.(type) {
@@ -271,7 +271,7 @@ func NetSetLimit(mgr network.ResourceManager, repo repo.Repo, scope string, limi
271 setLimit := func(s network.ResourceScope) error {
272 limiter, ok := s.(rcmgr.ResourceScopeLimiter)
273 if !ok { // NullResourceManager
274 - return NoResourceMgrError
274 + return ErrNoResourceMgr
275 }
276
277 limiter.SetLimit(&limit)
core/node/libp2p/transport.go
+2 -4
@@ -33,8 +33,7 @@ func Transports(tptConfig config.Transports) interface{} {
33 if tptConfig.Network.QUIC.WithDefault(!privateNetworkEnabled) {
34 if privateNetworkEnabled {
35 return opts, fmt.Errorf(
36 - "The QUIC transport does not support private networks. " +
37 - "Please disable Swarm.Transports.Network.QUIC.",
36 + "QUIC transport does not support private networks, please disable Swarm.Transports.Network.QUIC",
37 )
38 }
39 // TODO(9290): Make WithMetrics configurable
@@ -45,8 +44,7 @@ func Transports(tptConfig config.Transports) interface{} {
44 if tptConfig.Network.WebTransport.WithDefault(false && !privateNetworkEnabled) {
45 if privateNetworkEnabled {
46 return opts, fmt.Errorf(
48 - "The WebTransport transport does not support private networks. " +
49 - "Please disable Swarm.Transports.Network.WebTransport.",
47 + "WebTransport transport does not support private networks, please disable Swarm.Transports.Network.WebTransport",
48 )
49 }
50 opts.Opts = append(opts.Opts, libp2p.Transport(webtransport.New))
fuse/ipns/ipns_test.go
+2 -2
@@ -116,12 +116,12 @@ func setupIpnsTest(t *testing.T, node *core.IpfsNode) (*core.IpfsNode, *mountWra
116 }
117 }
118
119 - coreApi, err := coreapi.NewCoreAPI(node)
119 + coreAPI, err := coreapi.NewCoreAPI(node)
120 if err != nil {
121 t.Fatal(err)
122 }
123
124 - fs, err := NewFileSystem(node.Context(), coreApi, "", "")
124 + fs, err := NewFileSystem(node.Context(), coreAPI, "", "")
125 if err != nil {
126 t.Fatal(err)
127 }
fuse/ipns/ipns_unix.go
+20 -20
@@ -147,25 +147,25 @@ func CreateRoot(ctx context.Context, ipfs iface.CoreAPI, keys map[string]iface.K
147 }
148
149 // Attr returns file attributes.
150 -func (*Root) Attr(ctx context.Context, a *fuse.Attr) error {
150 +func (r *Root) Attr(ctx context.Context, a *fuse.Attr) error {
151 log.Debug("Root Attr")
152 a.Mode = os.ModeDir | 0111 // -rw+x
153 return nil
154 }
155
156 // Lookup performs a lookup under this node.
157 -func (s *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
157 +func (r *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
158 switch name {
159 case "mach_kernel", ".hidden", "._.":
160 // Just quiet some log noise on OS X.
161 return nil, fuse.ENOENT
162 }
163
164 - if lnk, ok := s.LocalLinks[name]; ok {
164 + if lnk, ok := r.LocalLinks[name]; ok {
165 return lnk, nil
166 }
167
168 - nd, ok := s.LocalDirs[name]
168 + nd, ok := r.LocalDirs[name]
169 if ok {
170 switch nd := nd.(type) {
171 case *Directory:
@@ -179,7 +179,7 @@ func (s *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
179
180 // other links go through ipns resolution and are symlinked into the ipfs mountpoint
181 ipnsName := "/ipns/" + name
182 - resolved, err := s.Ipfs.Name().Resolve(ctx, ipnsName)
182 + resolved, err := r.Ipfs.Name().Resolve(ctx, ipnsName)
183 if err != nil {
184 log.Warnf("ipns: namesys resolve error: %s", err)
185 return nil, fuse.ENOENT
@@ -189,7 +189,7 @@ func (s *Root) Lookup(ctx context.Context, name string) (fs.Node, error) {
189 return nil, errors.New("invalid path from ipns record")
190 }
191
192 - return &Link{s.IpfsRoot + "/" + strings.TrimPrefix(resolved.String(), "/ipfs/")}, nil
192 + return &Link{r.IpfsRoot + "/" + strings.TrimPrefix(resolved.String(), "/ipfs/")}, nil
193 }
194
195 func (r *Root) Close() error {
@@ -270,8 +270,8 @@ func (fi *FileNode) Attr(ctx context.Context, a *fuse.Attr) error {
270 }
271
272 // Lookup performs a lookup under this node.
273 -func (s *Directory) Lookup(ctx context.Context, name string) (fs.Node, error) {
274 - child, err := s.dir.Child(name)
273 +func (d *Directory) Lookup(ctx context.Context, name string) (fs.Node, error) {
274 + child, err := d.dir.Child(name)
275 if err != nil {
276 // todo: make this error more versatile.
277 return nil, fuse.ENOENT
@@ -290,8 +290,8 @@ func (s *Directory) Lookup(ctx context.Context, name string) (fs.Node, error) {
290 }
291
292 // ReadDirAll reads the link structure as directory entries
293 -func (dir *Directory) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
294 - listing, err := dir.dir.List(ctx)
293 +func (d *Directory) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
294 + listing, err := d.dir.List(ctx)
295 if err != nil {
296 return nil, err
297 }
@@ -401,8 +401,8 @@ func (fi *File) Forget() {
401 }
402 }
403
404 -func (dir *Directory) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, error) {
405 - child, err := dir.dir.Mkdir(req.Name)
404 +func (d *Directory) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, error) {
405 + child, err := d.dir.Mkdir(req.Name)
406 if err != nil {
407 return nil, err
408 }
@@ -451,15 +451,15 @@ func (fi *File) Release(ctx context.Context, req *fuse.ReleaseRequest) error {
451 return fi.fi.Close()
452 }
453
454 -func (dir *Directory) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (fs.Node, fs.Handle, error) {
454 +func (d *Directory) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (fs.Node, fs.Handle, error) {
455 // New 'empty' file
456 nd := dag.NodeWithData(ft.FilePBData(nil, 0))
457 - err := dir.dir.AddChild(req.Name, nd)
457 + err := d.dir.AddChild(req.Name, nd)
458 if err != nil {
459 return nil, nil, err
460 }
461
462 - child, err := dir.dir.Child(req.Name)
462 + child, err := d.dir.Child(req.Name)
463 if err != nil {
464 return nil, nil, err
465 }
@@ -483,8 +483,8 @@ func (dir *Directory) Create(ctx context.Context, req *fuse.CreateRequest, resp
483 return nodechild, &File{fi: fd}, nil
484 }
485
486 -func (dir *Directory) Remove(ctx context.Context, req *fuse.RemoveRequest) error {
487 - err := dir.dir.Unlink(req.Name)
486 +func (d *Directory) Remove(ctx context.Context, req *fuse.RemoveRequest) error {
487 + err := d.dir.Unlink(req.Name)
488 if err != nil {
489 return fuse.ENOENT
490 }
@@ -492,13 +492,13 @@ func (dir *Directory) Remove(ctx context.Context, req *fuse.RemoveRequest) error
492 }
493
494 // Rename implements NodeRenamer
495 -func (dir *Directory) Rename(ctx context.Context, req *fuse.RenameRequest, newDir fs.Node) error {
496 - cur, err := dir.dir.Child(req.OldName)
495 +func (d *Directory) Rename(ctx context.Context, req *fuse.RenameRequest, newDir fs.Node) error {
496 + cur, err := d.dir.Child(req.OldName)
497 if err != nil {
498 return err
499 }
500
501 - err = dir.dir.Unlink(req.OldName)
501 + err = d.dir.Unlink(req.OldName)
502 if err != nil {
503 return err
504 }
fuse/ipns/mount_unix.go
+4 -4
@@ -12,7 +12,7 @@ import (
12
13 // Mount mounts ipns at a given location, and returns a mount.Mount instance.
14 func Mount(ipfs *core.IpfsNode, ipnsmp, ipfsmp string) (mount.Mount, error) {
15 - coreApi, err := coreapi.NewCoreAPI(ipfs)
15 + coreAPI, err := coreapi.NewCoreAPI(ipfs)
16 if err != nil {
17 return nil, err
18 }
@@ -22,12 +22,12 @@ func Mount(ipfs *core.IpfsNode, ipnsmp, ipfsmp string) (mount.Mount, error) {
22 return nil, err
23 }
24
25 - allow_other := cfg.Mounts.FuseAllowOther
25 + allowOther := cfg.Mounts.FuseAllowOther
26
27 - fsys, err := NewFileSystem(ipfs.Context(), coreApi, ipfsmp, ipnsmp)
27 + fsys, err := NewFileSystem(ipfs.Context(), coreAPI, ipfsmp, ipnsmp)
28 if err != nil {
29 return nil, err
30 }
31
32 - return mount.NewMount(ipfs.Process, fsys, ipnsmp, allow_other)
32 + return mount.NewMount(ipfs.Process, fsys, ipnsmp, allowOther)
33 }
fuse/mount/fuse.go
+2 -2
@@ -30,7 +30,7 @@ type mount struct {
30
31 // Mount mounts a fuse fs.FS at a given location, and returns a Mount instance.
32 // parent is a ContextGroup to bind the mount's ContextGroup to.
33 -func NewMount(p goprocess.Process, fsys fs.FS, mountpoint string, allow_other bool) (Mount, error) {
33 +func NewMount(p goprocess.Process, fsys fs.FS, mountpoint string, allowOther bool) (Mount, error) {
34 var conn *fuse.Conn
35 var err error
36
@@ -39,7 +39,7 @@ func NewMount(p goprocess.Process, fsys fs.FS, mountpoint string, allow_other bo
39 fuse.AsyncRead(),
40 }
41
42 - if allow_other {
42 + if allowOther {
43 mountOpts = append(mountOpts, fuse.AllowOther())
44 }
45 conn, err = fuse.Mount(mountpoint, mountOpts...)
fuse/readonly/mount_unix.go
+2 -2
@@ -15,7 +15,7 @@ func Mount(ipfs *core.IpfsNode, mountpoint string) (mount.Mount, error) {
15 if err != nil {
16 return nil, err
17 }
18 - allow_other := cfg.Mounts.FuseAllowOther
18 + allowOther := cfg.Mounts.FuseAllowOther
19 fsys := NewFileSystem(ipfs)
20 - return mount.NewMount(ipfs.Process, fsys, mountpoint, allow_other)
20 + return mount.NewMount(ipfs.Process, fsys, mountpoint, allowOther)
21 }
fuse/readonly/readonly_unix.go
+2 -2
@@ -180,11 +180,11 @@ func (s *Node) Lookup(ctx context.Context, name string) (fs.Node, error) {
180 case os.ErrNotExist, mdag.ErrLinkNotFound:
181 // todo: make this error more versatile.
182 return nil, fuse.ENOENT
183 + case nil:
184 + // noop
185 default:
186 log.Errorf("fuse lookup %q: %s", name, err)
187 return nil, fuse.EIO
186 - case nil:
187 - // noop
188 }
189
190 nd, err := s.Ipfs.DAG.Get(ctx, link.Cid)
gc/gc.go
+1 -1
@@ -167,7 +167,7 @@ func Descendants(ctx context.Context, getLinks dag.GetLinks, set *cid.Set, roots
167 verboseCidError := func(err error) error {
168 if strings.Contains(err.Error(), verifcid.ErrBelowMinimumHashLength.Error()) ||
169 strings.Contains(err.Error(), verifcid.ErrPossiblyInsecureHashFunction.Error()) {
170 - err = fmt.Errorf("\"%s\"\nPlease run 'ipfs pin verify'"+
170 + err = fmt.Errorf("\"%s\"\nPlease run 'ipfs pin verify'"+ //nolint
171 " to list insecure hashes. If you want to read them,"+
172 " please downgrade your go-ipfs to 0.4.13\n", err)
173 log.Error(err)
repo/fsrepo/fsrepo.go
+3 -3
@@ -35,7 +35,7 @@ const LockFile = "repo.lock"
35
36 var log = logging.Logger("fsrepo")
37
38 -// version number that we are currently expecting to see
38 +// RepoVersion is the version number that we are currently expecting to see
39 var RepoVersion = 12
40
41 var migrationInstructions = `See https://github.com/ipfs/fs-repo-migrations/blob/master/run.md
@@ -383,7 +383,7 @@ func (r *FSRepo) SetAPIAddr(addr ma.Multiaddr) error {
383 }
384 // Remove the temp file when rename return error
385 if err1 := os.Remove(filepath.Join(r.path, "."+apiFile+".tmp")); err1 != nil {
386 - return fmt.Errorf("File Rename error: %s, File remove error: %s", err.Error(),
386 + return fmt.Errorf("file Rename error: %s, file remove error: %s", err.Error(),
387 err1.Error())
388 }
389 return err
@@ -422,7 +422,7 @@ func (r *FSRepo) SetGatewayAddr(addr net.Addr) error {
422 }
423 // Remove the temp file when rename return error
424 if err1 := os.Remove(tmpPath); err1 != nil {
425 - return fmt.Errorf("File Rename error: %w, File remove error: %s", err, err1.Error())
425 + return fmt.Errorf("file Rename error: %w, file remove error: %s", err, err1.Error())
426 }
427 return err
428 }
repo/fsrepo/migrations/httpfetcher.go
+2 -2
@@ -16,7 +16,7 @@ const (
16 )
17
18 // HttpFetcher fetches files over HTTP
19 -type HttpFetcher struct {
19 +type HttpFetcher struct { //nolint
20 distPath string
21 gateway string
22 limit int64
@@ -30,7 +30,7 @@ var _ Fetcher = (*HttpFetcher)(nil)
30 // Specifying "" for distPath sets the default IPNS path.
31 // Specifying "" for gateway sets the default.
32 // Specifying 0 for fetchLimit sets the default, -1 means no limit.
33 -func NewHttpFetcher(distPath, gateway, userAgent string, fetchLimit int64) *HttpFetcher {
33 +func NewHttpFetcher(distPath, gateway, userAgent string, fetchLimit int64) *HttpFetcher { //nolint
34 f := &HttpFetcher{
35 distPath: LatestIpfsDist,
36 gateway: defaultGatewayURL,
repo/fsrepo/migrations/ipfsfetcher/ipfsfetcher.go
+2 -2
@@ -28,7 +28,7 @@ const (
28 // Default maximum download size
29 defaultFetchLimit = 1024 * 1024 * 512
30
31 - tempNodeTcpAddr = "/ip4/127.0.0.1/tcp/0"
31 + tempNodeTCPAddr = "/ip4/127.0.0.1/tcp/0"
32 )
33
34 type IpfsFetcher struct {
@@ -193,7 +193,7 @@ func initTempNode(ctx context.Context, bootstrap []string, peers []peer.AddrInfo
193 // Disable listening for inbound connections
194 cfg.Addresses.Gateway = []string{}
195 cfg.Addresses.API = []string{}
196 - cfg.Addresses.Swarm = []string{tempNodeTcpAddr}
196 + cfg.Addresses.Swarm = []string{tempNodeTCPAddr}
197
198 if len(bootstrap) != 0 {
199 cfg.Bootstrap = bootstrap
repo/fsrepo/migrations/migrations.go
+2 -2
@@ -166,6 +166,8 @@ func GetMigrationFetcher(downloadSources []string, distPath string, newIpfsFetch
166 if newIpfsFetcher != nil {
167 fetchers = append(fetchers, newIpfsFetcher(distPath))
168 }
169 + case "":
170 + // Ignore empty string
171 default:
172 u, err := url.Parse(src)
173 if err != nil {
@@ -179,8 +181,6 @@ func GetMigrationFetcher(downloadSources []string, distPath string, newIpfsFetch
181 return nil, errors.New("bad gateway address: url scheme must be http or https")
182 }
183 fetchers = append(fetchers, &RetryFetcher{NewHttpFetcher(distPath, u.String(), httpUserAgent, 0), numTriesPerHTTP})
182 - case "":
183 - // Ignore empty string
184 }
185 }
186
repo/repo.go
+1 -1
@@ -15,7 +15,7 @@ import (
15 )
16
17 var (
18 - ErrApiNotRunning = errors.New("api not running")
18 + ErrApiNotRunning = errors.New("api not running") //nolint
19 )
20
21 // Repo represents all persistent data of a given ipfs node.
test/integration/addcat_test.go
+4 -4
@@ -122,12 +122,12 @@ func DirectAddCat(data []byte, conf testutil.LatencyConfig) error {
122 }
123 defer catter.Close()
124
125 - adderApi, err := coreapi.NewCoreAPI(adder)
125 + adderAPI, err := coreapi.NewCoreAPI(adder)
126 if err != nil {
127 return err
128 }
129
130 - catterApi, err := coreapi.NewCoreAPI(catter)
130 + catterAPI, err := coreapi.NewCoreAPI(catter)
131 if err != nil {
132 return err
133 }
@@ -147,12 +147,12 @@ func DirectAddCat(data []byte, conf testutil.LatencyConfig) error {
147 return err
148 }
149
150 - added, err := adderApi.Unixfs().Add(ctx, files.NewBytesFile(data))
150 + added, err := adderAPI.Unixfs().Add(ctx, files.NewBytesFile(data))
151 if err != nil {
152 return err
153 }
154
155 - readerCatted, err := catterApi.Unixfs().Get(ctx, added)
155 + readerCatted, err := catterAPI.Unixfs().Get(ctx, added)
156 if err != nil {
157 return err
158 }
test/integration/bench_cat_test.go
+4 -4
@@ -65,12 +65,12 @@ func benchCat(b *testing.B, data []byte, conf testutil.LatencyConfig) error {
65 }
66 defer catter.Close()
67
68 - adderApi, err := coreapi.NewCoreAPI(adder)
68 + adderAPI, err := coreapi.NewCoreAPI(adder)
69 if err != nil {
70 return err
71 }
72
73 - catterApi, err := coreapi.NewCoreAPI(catter)
73 + catterAPI, err := coreapi.NewCoreAPI(catter)
74 if err != nil {
75 return err
76 }
@@ -90,13 +90,13 @@ func benchCat(b *testing.B, data []byte, conf testutil.LatencyConfig) error {
90 return err
91 }
92
93 - added, err := adderApi.Unixfs().Add(ctx, files.NewBytesFile(data))
93 + added, err := adderAPI.Unixfs().Add(ctx, files.NewBytesFile(data))
94 if err != nil {
95 return err
96 }
97
98 b.StartTimer()
99 - readerCatted, err := catterApi.Unixfs().Get(ctx, added)
99 + readerCatted, err := catterAPI.Unixfs().Get(ctx, added)
100 if err != nil {
101 return err
102 }
test/integration/three_legged_cat_test.go
+4 -4
@@ -93,12 +93,12 @@ func RunThreeLeggedCat(data []byte, conf testutil.LatencyConfig) error {
93 }
94 defer catter.Close()
95
96 - adderApi, err := coreapi.NewCoreAPI(adder)
96 + adderAPI, err := coreapi.NewCoreAPI(adder)
97 if err != nil {
98 return err
99 }
100
101 - catterApi, err := coreapi.NewCoreAPI(catter)
101 + catterAPI, err := coreapi.NewCoreAPI(catter)
102 if err != nil {
103 return err
104 }
@@ -117,12 +117,12 @@ func RunThreeLeggedCat(data []byte, conf testutil.LatencyConfig) error {
117 return err
118 }
119
120 - added, err := adderApi.Unixfs().Add(ctx, files.NewBytesFile(data))
120 + added, err := adderAPI.Unixfs().Add(ctx, files.NewBytesFile(data))
121 if err != nil {
122 return err
123 }
124
125 - readerCatted, err := catterApi.Unixfs().Get(ctx, added)
125 + readerCatted, err := catterAPI.Unixfs().Get(ctx, added)
126 if err != nil {
127 return err
128 }
test/sharness/t0320-pubsub.sh
+1 -1
@@ -158,7 +158,7 @@ test_expect_success 'pubsub cmd fails because it was disabled via cli flag' '
158 '
159
160 test_expect_success "pubsub cmd produces error" '
161 - echo "Error: experimental pubsub feature not enabled. Run daemon with --enable-pubsub-experiment to use." > expected &&
161 + echo "Error: experimental pubsub feature not enabled, run daemon with --enable-pubsub-experiment to use" > expected &&
162 test_cmp expected pubsub_cmd_out
163 '
164
version.go
+1 -1
@@ -13,7 +13,7 @@ var CurrentCommit string
13 // CurrentVersionNumber is the current application's version literal
14 const CurrentVersionNumber = "0.17.0-dev"
15
16 -const ApiVersion = "/kubo/" + CurrentVersionNumber + "/"
16 +const ApiVersion = "/kubo/" + CurrentVersionNumber + "/" //nolint
17
18 // GetUserAgentVersion is the libp2p user agent used by go-ipfs.
19 //