fmt: applies go1.19 fmt
Jorropo committed
Sep 3, 2022 at 15:47 UTC
82fbb84384d04be3433deb993af37f927432198c
12 files changed
+131
-135
config/config.go
+5
-5
@@ -78,11 +78,11 @@ func Path(configroot, extension string) (string, error) {
78
// Filename returns the configuration file path given a configuration root
79
// directory and a user-provided configuration file path argument with the
80
// following rules:
81
-// * If the user-provided configuration file path is empty, use the default one.
82
-// * If the configuration root directory is empty, use the default one.
83
-// * If the user-provided configuration file path is only a file name, use the
84
-// configuration root directory, otherwise use only the user-provided path
85
-// and ignore the configuration root.
81
+// - If the user-provided configuration file path is empty, use the default one.
82
+// - If the configuration root directory is empty, use the default one.
83
+// - If the user-provided configuration file path is only a file name, use the
84
+// configuration root directory, otherwise use only the user-provided path
85
+// and ignore the configuration root.
86
func Filename(configroot string, userConfigFile string) (string, error) {
87
if userConfigFile == "" {
88
return Path(configroot, DefaultConfigFile)
core/commands/config.go
+1
@@ -152,6 +152,7 @@ Set the value of the 'Datastore.Path' key:
152
// A pattern matches a part if and only if the pattern is "*" or the lowercase pattern equals the lowercase part.
153
//
154
// For example:
155
+//
156
// matchesGlobPrefix("foo.bar", []string{"*", "bar", "baz"}) returns true
157
// matchesGlobPrefix("foo.bar.baz", []string{"*", "bar"}) returns true
158
// matchesGlobPrefix("foo.bar", []string{"baz", "*"}) returns false
core/core.go
+1
-1
@@ -5,7 +5,7 @@ Packages underneath core/ provide a (relatively) stable, low-level API
5
to carry out most IPFS-related tasks. For more details on the other
6
interfaces and how core/... fits into the bigger IPFS picture, see:
7
8
- $ godoc github.com/ipfs/go-ipfs
8
+ $ godoc github.com/ipfs/go-ipfs
9
*/
10
package core
11
core/node/helpers.go
+1
-1
@@ -43,7 +43,7 @@ func maybeProvide(opt interface{}, enable bool) fx.Option {
43
return fx.Options()
44
}
45
46
-//nolint unused
46
+// nolint unused
47
func maybeInvoke(opt interface{}, enable bool) fx.Option {
48
if enable {
49
return fx.Invoke(opt)
plugin/loader/loader.go
+6
-6
@@ -79,12 +79,12 @@ func (ls loaderState) String() string {
79
// PluginLoader keeps track of loaded plugins.
80
//
81
// To use:
82
-// 1. Load any desired plugins with Load and LoadDirectory. Preloaded plugins
83
-// will automatically be loaded.
84
-// 2. Call Initialize to run all initialization logic.
85
-// 3. Call Inject to register the plugins.
86
-// 4. Optionally call Start to start plugins.
87
-// 5. Call Close to close all plugins.
82
+// 1. Load any desired plugins with Load and LoadDirectory. Preloaded plugins
83
+// will automatically be loaded.
84
+// 2. Call Initialize to run all initialization logic.
85
+// 3. Call Inject to register the plugins.
86
+// 4. Optionally call Start to start plugins.
87
+// 5. Call Close to close all plugins.
88
type PluginLoader struct {
89
state loaderState
90
plugins map[string]plugin.Plugin
plugin/plugins/peerlog/peerlog.go
+5
-3
@@ -39,11 +39,13 @@ type plEvent struct {
39
// Log all the PeerIDs. This is considered internal, unsupported, and may break at any point.
40
//
41
// Usage:
42
-// GOLOG_FILE=~/peer.log IPFS_LOGGING_FMT=json ipfs daemon
42
+//
43
+// GOLOG_FILE=~/peer.log IPFS_LOGGING_FMT=json ipfs daemon
44
+//
45
// Output:
44
-// {"level":"info","ts":"2020-02-10T13:54:26.639Z","logger":"plugin/peerlog","caller":"peerlog/peerlog.go:51","msg":"connected","peer":"QmS2H72gdrekXJggGdE9SunXPntBqdkJdkXQJjuxcH8Cbt"}
45
-// {"level":"info","ts":"2020-02-10T13:54:59.095Z","logger":"plugin/peerlog","caller":"peerlog/peerlog.go:56","msg":"identified","peer":"QmS2H72gdrekXJggGdE9SunXPntBqdkJdkXQJjuxcH8Cbt","agent":"go-ipfs/0.5.0/"}
46
//
47
+// {"level":"info","ts":"2020-02-10T13:54:26.639Z","logger":"plugin/peerlog","caller":"peerlog/peerlog.go:51","msg":"connected","peer":"QmS2H72gdrekXJggGdE9SunXPntBqdkJdkXQJjuxcH8Cbt"}
48
+// {"level":"info","ts":"2020-02-10T13:54:59.095Z","logger":"plugin/peerlog","caller":"peerlog/peerlog.go:56","msg":"identified","peer":"QmS2H72gdrekXJggGdE9SunXPntBqdkJdkXQJjuxcH8Cbt","agent":"go-ipfs/0.5.0/"}
49
type peerLogPlugin struct {
50
enabled bool
51
droppedCount uint64
repo/fsrepo/doc.go
+13
-13
@@ -2,19 +2,19 @@
2
//
3
// TODO explain the package roadmap...
4
//
5
-// .ipfs/
6
-// ├── client/
7
-// | ├── client.lock <------ protects client/ + signals its own pid
8
-// │ ├── ipfs-client.cpuprof
9
-// │ └── ipfs-client.memprof
10
-// ├── config
11
-// ├── daemon/
12
-// │ ├── daemon.lock <------ protects daemon/ + signals its own address
13
-// │ ├── ipfs-daemon.cpuprof
14
-// │ └── ipfs-daemon.memprof
15
-// ├── datastore/
16
-// ├── repo.lock <------ protects datastore/ and config
17
-// └── version
5
+// .ipfs/
6
+// ├── client/
7
+// | ├── client.lock <------ protects client/ + signals its own pid
8
+// │ ├── ipfs-client.cpuprof
9
+// │ └── ipfs-client.memprof
10
+// ├── config
11
+// ├── daemon/
12
+// │ ├── daemon.lock <------ protects daemon/ + signals its own address
13
+// │ ├── ipfs-daemon.cpuprof
14
+// │ └── ipfs-daemon.memprof
15
+// ├── datastore/
16
+// ├── repo.lock <------ protects datastore/ and config
17
+// └── version
18
package fsrepo
19
20
// TODO prevent multiple daemons from running
repo/fsrepo/fsrepo.go
+11
-11
@@ -582,17 +582,17 @@ func (r *FSRepo) BackupConfig(prefix string) (string, error) {
582
// SetConfig updates the FSRepo's config. The user must not modify the config
583
// object after calling this method.
584
// FIXME: There is an inherent contradiction with storing non-user-generated
585
-// Go config.Config structures as user-generated JSON nested maps. This is
586
-// evidenced by the issue of `omitempty` property of fields that aren't defined
587
-// by the user and Go still needs to initialize them to its default (which
588
-// is not reflected in the repo's config file, see
589
-// https://github.com/ipfs/kubo/issues/8088 for more details).
590
-// In general we should call this API with a JSON nested maps as argument
591
-// (`map[string]interface{}`). Many calls to this function are forced to
592
-// synthesize the config.Config struct from their available JSON map just to
593
-// satisfy this (causing incompatibilities like the `omitempty` one above).
594
-// We need to comb SetConfig calls and replace them when possible with a
595
-// JSON map variant.
585
+// Go config.Config structures as user-generated JSON nested maps. This is
586
+// evidenced by the issue of `omitempty` property of fields that aren't defined
587
+// by the user and Go still needs to initialize them to its default (which
588
+// is not reflected in the repo's config file, see
589
+// https://github.com/ipfs/kubo/issues/8088 for more details).
590
+// In general we should call this API with a JSON nested maps as argument
591
+// (`map[string]interface{}`). Many calls to this function are forced to
592
+// synthesize the config.Config struct from their available JSON map just to
593
+// satisfy this (causing incompatibilities like the `omitempty` one above).
594
+// We need to comb SetConfig calls and replace them when possible with a
595
+// JSON map variant.
596
func (r *FSRepo) SetConfig(updated *config.Config) error {
597
598
// packageLock is held to provide thread-safety.
repo/fsrepo/migrations/fetch.go
+4
-4
@@ -26,7 +26,7 @@ var DownloadDirectory string
26
// is needed because the archive "go-ipfs_v0.7.0_linux-amd64.tar.gz" contains a
27
// binary named "ipfs"
28
//
29
-// FetchBinary(ctx, fetcher, "go-ipfs", "v0.7.0", "ipfs", tmpDir)
29
+// FetchBinary(ctx, fetcher, "go-ipfs", "v0.7.0", "ipfs", tmpDir)
30
//
31
// If out is a directory, then the binary is written to that directory with the
32
// same name it has inside the archive. Otherwise, the binary file is written
@@ -178,9 +178,9 @@ func osWithVariant() (string, error) {
178
// Returns the archive path and the base name.
179
//
180
// The ipfs path format is: distribution/version/archiveName
181
-// - distribution is the name of a distribution, such as "go-ipfs"
182
-// - version is the version to fetch, such as "v0.8.0-rc2"
183
-// - archiveName is formatted as name_version_osv-GOARCH.atype, such as
181
+// - distribution is the name of a distribution, such as "go-ipfs"
182
+// - version is the version to fetch, such as "v0.8.0-rc2"
183
+// - archiveName is formatted as name_version_osv-GOARCH.atype, such as
184
// "go-ipfs_v0.8.0-rc2_linux-amd64.tar.gz"
185
//
186
// This would form the path:
repo/onlyone.go
+2
-2
@@ -19,8 +19,8 @@ type OnlyOne struct {
19
// that are unique across different concrete Repo implementations,
20
// e.g. by creating a local type:
21
//
22
-// type repoKey string
23
-// r, err := o.Open(repoKey(path), open)
22
+// type repoKey string
23
+// r, err := o.Open(repoKey(path), open)
24
//
25
// Call Repo.Close when done.
26
func (o *OnlyOne) Open(key interface{}, open func() (Repo, error)) (Repo, error) {
thirdparty/notifier/notifier.go
+43
-47
@@ -14,23 +14,21 @@ import (
14
// their own Notifiee interfaces to ensure type-safety
15
// of notifications:
16
//
17
-// type RocketNotifiee interface{
18
-// Countdown(r Rocket, countdown time.Duration)
19
-// LiftedOff(Rocket)
20
-// ReachedOrbit(Rocket)
21
-// Detached(Rocket, Capsule)
22
-// Landed(Rocket)
23
-// }
24
-//
17
+// type RocketNotifiee interface{
18
+// Countdown(r Rocket, countdown time.Duration)
19
+// LiftedOff(Rocket)
20
+// ReachedOrbit(Rocket)
21
+// Detached(Rocket, Capsule)
22
+// Landed(Rocket)
23
+// }
24
type Notifiee interface{}
25
26
// Notifier is a notification dispatcher. It's meant
27
// to be composed, and its zero-value is ready to be used.
28
//
30
-// type Rocket struct {
31
-// notifier notifier.Notifier
32
-// }
33
-//
29
+// type Rocket struct {
30
+// notifier notifier.Notifier
31
+// }
32
type Notifier struct {
33
mu sync.RWMutex // guards notifiees
34
nots map[Notifiee]struct{}
@@ -51,17 +49,16 @@ func RateLimited(limit int) *Notifier {
49
// Notify signs up Notifiee e for notifications. This function
50
// is meant to be called behind your own type-safe function(s):
51
//
54
-// // generic function for pattern-following
55
-// func (r *Rocket) Notify(n Notifiee) {
56
-// r.notifier.Notify(n)
57
-// }
58
-//
59
-// // or as part of other functions
60
-// func (r *Rocket) Onboard(a Astronaut) {
61
-// r.astronauts = append(r.austronauts, a)
62
-// r.notifier.Notify(a)
63
-// }
52
+// // generic function for pattern-following
53
+// func (r *Rocket) Notify(n Notifiee) {
54
+// r.notifier.Notify(n)
55
+// }
56
//
57
+// // or as part of other functions
58
+// func (r *Rocket) Onboard(a Astronaut) {
59
+// r.astronauts = append(r.austronauts, a)
60
+// r.notifier.Notify(a)
61
+// }
62
func (n *Notifier) Notify(e Notifiee) {
63
n.mu.Lock()
64
if n.nots == nil { // so that zero-value is ready to be used.
@@ -74,17 +71,16 @@ func (n *Notifier) Notify(e Notifiee) {
71
// StopNotify stops notifying Notifiee e. This function
72
// is meant to be called behind your own type-safe function(s):
73
//
77
-// // generic function for pattern-following
78
-// func (r *Rocket) StopNotify(n Notifiee) {
79
-// r.notifier.StopNotify(n)
80
-// }
81
-//
82
-// // or as part of other functions
83
-// func (r *Rocket) Detach(c Capsule) {
84
-// r.notifier.StopNotify(c)
85
-// r.capsule = nil
86
-// }
74
+// // generic function for pattern-following
75
+// func (r *Rocket) StopNotify(n Notifiee) {
76
+// r.notifier.StopNotify(n)
77
+// }
78
//
79
+// // or as part of other functions
80
+// func (r *Rocket) Detach(c Capsule) {
81
+// r.notifier.StopNotify(c)
82
+// r.capsule = nil
83
+// }
84
func (n *Notifier) StopNotify(e Notifiee) {
85
n.mu.Lock()
86
if n.nots != nil { // so that zero-value is ready to be used.
@@ -97,22 +93,22 @@ func (n *Notifier) StopNotify(e Notifiee) {
93
// This is done by calling the given function with each notifiee. It is
94
// meant to be called with your own type-safe notification functions:
95
//
100
-// func (r *Rocket) Launch() {
101
-// r.notifyAll(func(n Notifiee) {
102
-// n.Launched(r)
103
-// })
104
-// }
96
+// func (r *Rocket) Launch() {
97
+// r.notifyAll(func(n Notifiee) {
98
+// n.Launched(r)
99
+// })
100
+// }
101
//
106
-// // make it private so only you can use it. This function is necessary
107
-// // to make sure you only up-cast in one place. You control who you added
108
-// // to be a notifiee. If Go adds generics, maybe we can get rid of this
109
-// // method but for now it is like wrapping a type-less container with
110
-// // a type safe interface.
111
-// func (r *Rocket) notifyAll(notify func(Notifiee)) {
112
-// r.notifier.NotifyAll(func(n notifier.Notifiee) {
113
-// notify(n.(Notifiee))
114
-// })
115
-// }
102
+// // make it private so only you can use it. This function is necessary
103
+// // to make sure you only up-cast in one place. You control who you added
104
+// // to be a notifiee. If Go adds generics, maybe we can get rid of this
105
+// // method but for now it is like wrapping a type-less container with
106
+// // a type safe interface.
107
+// func (r *Rocket) notifyAll(notify func(Notifiee)) {
108
+// r.notifier.NotifyAll(func(n notifier.Notifiee) {
109
+// notify(n.(Notifiee))
110
+// })
111
+// }
112
//
113
// Note well: each notification is launched in its own goroutine, so they
114
// can be processed concurrently, and so that whatever the notification does
tracing/doc.go
+39
-42
@@ -8,70 +8,67 @@
8
//
9
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md
10
//
11
-// - OTEL_TRACES_EXPORTER: a comma-separated list of exporters
12
-// - otlp
13
-// - jaeger
14
-// - zipkin
15
-// - file
11
+// OTEL_TRACES_EXPORTER: a comma-separated list of exporters:
12
+// - otlp
13
+// - jaeger
14
+// - zipkin
15
+// - file
16
//
17
// Different exporters have their own set of environment variables, depending on the exporter. These are typically
18
// standard environment variables. Some common ones:
19
//
20
// Jaeger:
21
//
22
-// - OTEL_EXPORTER_JAEGER_AGENT_HOST
23
-// - OTEL_EXPORTER_JAEGER_AGENT_PORT
24
-// - OTEL_EXPORTER_JAEGER_ENDPOINT
25
-// - OTEL_EXPORTER_JAEGER_USER
26
-// - OTEL_EXPORTER_JAEGER_PASSWORD
22
+// - OTEL_EXPORTER_JAEGER_AGENT_HOST
23
+// - OTEL_EXPORTER_JAEGER_AGENT_PORT
24
+// - OTEL_EXPORTER_JAEGER_ENDPOINT
25
+// - OTEL_EXPORTER_JAEGER_USER
26
+// - OTEL_EXPORTER_JAEGER_PASSWORD
27
//
28
// OTLP HTTP/gRPC:
29
//
30
-// - OTEL_EXPORTER_OTLP_PROTOCOL
31
-// - one of [grpc, http/protobuf]
32
-// - default: grpc
33
-// - OTEL_EXPORTER_OTLP_ENDPOINT
34
-// - OTEL_EXPORTER_OTLP_CERTIFICATE
35
-// - OTEL_EXPORTER_OTLP_HEADERS
36
-// - OTEL_EXPORTER_OTLP_COMPRESSION
37
-// - OTEL_EXPORTER_OTLP_TIMEOUT
30
+// - OTEL_EXPORTER_OTLP_PROTOCOL
31
+// one of [grpc, http/protobuf]
32
+// default: grpc
33
+// - OTEL_EXPORTER_OTLP_ENDPOINT
34
+// - OTEL_EXPORTER_OTLP_CERTIFICATE
35
+// - OTEL_EXPORTER_OTLP_HEADERS
36
+// - OTEL_EXPORTER_OTLP_COMPRESSION
37
+// - OTEL_EXPORTER_OTLP_TIMEOUT
38
//
39
// Zipkin:
40
//
41
-// - OTEL_EXPORTER_ZIPKIN_ENDPOINT
41
+// - OTEL_EXPORTER_ZIPKIN_ENDPOINT
42
//
43
// File:
44
//
45
-// - OTEL_EXPORTER_FILE_PATH
46
-// - file path to write JSON traces
47
-// - default: `$PWD/traces.json`
45
+// - OTEL_EXPORTER_FILE_PATH
46
+// file path to write JSON traces
47
+// default: `$PWD/traces.json`
48
//
49
// For example, if you run a local IPFS daemon, you can use the jaegertracing/all-in-one Docker image to run
50
// a full Jaeger stack and configure go-ipfs to publish traces to it:
51
//
52
-// docker run -d --name jaeger \
53
-// -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
54
-// -p 5775:5775/udp \
55
-// -p 6831:6831/udp \
56
-// -p 6832:6832/udp \
57
-// -p 5778:5778 \
58
-// -p 16686:16686 \
59
-// -p 14268:14268 \
60
-// -p 14269:14269 \
61
-// -p 14250:14250 \
62
-// -p 9411:9411 \
63
-// jaegertracing/all-in-one
64
-// OTEL_TRACES_EXPORTER=jaeger ipfs daemon
65
-//
66
-// In this example the Jaeger UI is available at http://localhost:16686.
67
-//
68
-//
69
-// Implementer Notes
52
+// docker run -d --name jaeger \
53
+// -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
54
+// -p 5775:5775/udp \
55
+// -p 6831:6831/udp \
56
+// -p 6832:6832/udp \
57
+// -p 5778:5778 \
58
+// -p 16686:16686 \
59
+// -p 14268:14268 \
60
+// -p 14269:14269 \
61
+// -p 14250:14250 \
62
+// -p 9411:9411 \
63
+// jaegertracing/all-in-one
64
+// OTEL_TRACES_EXPORTER=jaeger ipfs daemon
65
+//
66
+// # In this example the Jaeger UI is available at http://localhost:16686.
67
//
68
// Span names follow a convention of <Component>.<Span>, some examples:
69
//
73
-// - component=Gateway + span=Request -> Gateway.Request
74
-// - component=CoreAPI.PinAPI + span=Verify.CheckPin -> CoreAPI.PinAPI.Verify.CheckPin
70
+// - component=Gateway + span=Request -> Gateway.Request
71
+// - component=CoreAPI.PinAPI + span=Verify.CheckPin -> CoreAPI.PinAPI.Verify.CheckPin
72
//
73
// We follow the OpenTelemetry convention of using whatever TracerProvider is registered globally.
74
package tracing