WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 20916ac

Browse files
committed
docs: cleanup ez package doc-comments
Update doc comments to use go 1.19 references. https://go.dev/doc/comment#doclinks
1 parent 0e6d739 commit 20916ac

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

ez/ez.go

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ type Params[T any] struct {
7676
// field named `SecretValues` in your configuration to map to a value
7777
// in your config named "secret-values" you can set:
7878
// Params {
79-
// DialsTagNameDecoder: caseconversion.DecodeGoCamelCase,
80-
// FileFieldNameEncoder: caseconversion.EncodeKebabCase,
79+
// DialsTagNameDecoder: caseconversion.DecodeGoCamelCase,
80+
// FileFieldNameEncoder: caseconversion.EncodeKebabCase,
8181
// }
8282
// Note that this does not affect the flags or environment variable
8383
// naming. To manipulate flag naming, see [Params.FlagConfig].
@@ -90,23 +90,23 @@ type Params[T any] struct {
9090
FlattenAnonymousFields bool
9191
}
9292

93-
// DecoderFactory should return the appropriate decoder based on the config file
93+
// DecoderFactory should return the appropriate [dials.Decoder] based on the config file
9494
// path that is passed as the string argument to DecoderFactory
9595
type DecoderFactory func(string) dials.Decoder
9696

97-
// DecoderFactoryWithParams should return the appropriate decoder based on the config file
98-
// path that is passed as the string argument to DecoderFactory
99-
// Params may provide useful context/arguments
97+
// DecoderFactoryWithParams should return the appropriate [dials.Decoder] based on the config file
98+
// path that is passed as the string argument to DecoderFactoryWIthParams
99+
// [Params] may provide useful context/arguments
100100
type DecoderFactoryWithParams[T any] func(string, Params[T]) dials.Decoder
101101

102102
// ConfigWithConfigPath is an interface config struct that supplies a
103103
// ConfigPath() method to indicate which file to read as the config file once
104104
// populated.
105105
type ConfigWithConfigPath[T any] interface {
106106
*T
107-
// ConfigPath implementations should return the configuration file to
108-
// be read as the first return-value, and true, or an empty string and
109-
// false.
107+
// ConfigPath implementations should return the path to the configuration file to
108+
// be read as the first return-value, and true, otherwise, an empty string and
109+
// false should be returned to indicate no config should be read.
110110
ConfigPath() (string, bool)
111111
}
112112

@@ -125,9 +125,9 @@ func fileSource(cfgPath string, decoder dials.Decoder, watch bool) (dials.Source
125125
return fsrc, nil
126126
}
127127

128-
// ConfigFileEnvFlag takes advantage of the ConfigWithConfigPath cfg to indicate
128+
// ConfigFileEnvFlag takes advantage of the [ConfigWithConfigPath] cfg to indicate
129129
// what file to read and uses the passed decoder.
130-
// Configuration values provided by the returned Dials are the result of
130+
// Configuration values provided by the returned [dials.Dials] are the result of
131131
// stacking the sources in the following order:
132132
// - configuration file
133133
// - environment variables
@@ -143,17 +143,20 @@ func ConfigFileEnvFlag[T any, TP ConfigWithConfigPath[T]](ctx context.Context, c
143143

144144
}
145145

146-
// ConfigFileEnvFlagDecoderFactoryParams takes advantage of the ConfigWithConfigPath cfg to indicate
147-
// what file to read and uses the passed decoder.
148-
// Configuration values provided by the returned Dials are the result of
146+
// ConfigFileEnvFlagDecoderFactoryParams takes advantage of the [ConfigWithConfigPath] cfg to
147+
// indicate what file to read and uses the passed decoder.
148+
//
149+
// Configuration values provided by the returned [dials.Dials] are the result of
149150
// stacking the sources in the following order:
150151
// - configuration file
151152
// - environment variables
152153
// - flags it registers with the standard library flags package
153154
//
154155
// The contents of cfg for the defaults
155156
// cfg.ConfigPath() is evaluated on the stacked config with the file-contents omitted (using a "blank" source)
156-
// It differs from ConfigFileEnvFlag by the signature of the decoder factory, (which requires a params struct in this function)
157+
//
158+
// It differs from [ConfigFileEnvFlag] by the signature of the decoder factory, (which requires a
159+
// [Params] struct in this function)
157160
func ConfigFileEnvFlagDecoderFactoryParams[T any, TP ConfigWithConfigPath[T]](ctx context.Context, cfg TP, df DecoderFactoryWithParams[T], params Params[T]) (*dials.Dials[T], error) {
158161
blank := sourcewrap.Blank{}
159162

@@ -271,40 +274,39 @@ func ConfigFileEnvFlagDecoderFactoryParams[T any, TP ConfigWithConfigPath[T]](ct
271274
return d, nil
272275
}
273276

274-
// YAMLConfigEnvFlag takes advantage of the ConfigWithConfigPath cfg, thinly
275-
// wraping ConfigFileEnvFlag with the decoder statically set to YAML.
277+
// YAMLConfigEnvFlag takes advantage of the [ConfigWithConfigPath] cfg, thinly
278+
// wrapping [ConfigFileEnvFlag] with the decoder statically set to YAML.
276279
func YAMLConfigEnvFlag[T any, TP ConfigWithConfigPath[T]](ctx context.Context, cfg TP, params Params[T]) (*dials.Dials[T], error) {
277280
return ConfigFileEnvFlag(ctx, cfg, func(string) dials.Decoder { return &yaml.Decoder{FlattenAnonymous: params.FlattenAnonymousFields} }, params)
278281
}
279282

280-
// JSONConfigEnvFlag takes advantage of the ConfigWithConfigPath cfg, thinly
281-
// wraping ConfigFileEnvFlag with the decoder statically set to JSON.
283+
// JSONConfigEnvFlag takes advantage of the [ConfigWithConfigPath] cfg, thinly
284+
// wrapping [ConfigFileEnvFlag] with the decoder statically set to JSON.
282285
func JSONConfigEnvFlag[T any, TP ConfigWithConfigPath[T]](ctx context.Context, cfg TP, params Params[T]) (*dials.Dials[T], error) {
283286
return ConfigFileEnvFlag(ctx, cfg, func(string) dials.Decoder { return &json.Decoder{} }, params)
284287
}
285288

286-
// CueConfigEnvFlag takes advantage of the ConfigWithConfigPath cfg, thinly
287-
// wraping ConfigFileEnvFlag with the decoder statically set to Cue.
289+
// CueConfigEnvFlag takes advantage of the [ConfigWithConfigPath] cfg, thinly
290+
// wrapping [ConfigFileEnvFlag] with the decoder statically set to Cue.
288291
func CueConfigEnvFlag[T any, TP ConfigWithConfigPath[T]](ctx context.Context, cfg TP, params Params[T]) (*dials.Dials[T], error) {
289292
return ConfigFileEnvFlag(ctx, cfg, func(string) dials.Decoder { return &cue.Decoder{} }, params)
290293
}
291294

292-
// TOMLConfigEnvFlag takes advantage of the ConfigWithConfigPath cfg, thinly
293-
// wraping ConfigFileEnvFlag with the decoder statically set to TOML.
295+
// TOMLConfigEnvFlag takes advantage of the [ConfigWithConfigPath] cfg, thinly
296+
// wrapping [ConfigFileEnvFlag] with the decoder statically set to TOML.
294297
func TOMLConfigEnvFlag[T any, TP ConfigWithConfigPath[T]](ctx context.Context, cfg TP, params Params[T]) (*dials.Dials[T], error) {
295298
return ConfigFileEnvFlag(ctx, cfg, func(string) dials.Decoder { return &toml.Decoder{} }, params)
296299
}
297300

298-
// DecoderFromExtension is a DecoderFactory that returns an appropriate decoder
301+
// DecoderFromExtension is a [DecoderFactory] that returns an appropriate decoder
299302
// based on the extension of the filename or nil if there is not an appropriate
300303
// mapping.
301304
func DecoderFromExtension(path string) dials.Decoder {
302305
return DecoderFromExtensionWithParams(path, Params[struct{}]{})
303306
}
304307

305-
// DecoderFromExtension is a DecoderFactory that returns an appropriate decoder
306-
// based on the extension of the filename or nil if there is not an appropriate
307-
// mapping.
308+
// DecoderFromExtensionWithParams is a [DecoderFactoryWithParams] that returns an appropriate
309+
// decoder based on the extension of the filename or nil if there is not an appropriate mapping.
308310
func DecoderFromExtensionWithParams[T any](path string, p Params[T]) dials.Decoder {
309311
ext := filepath.Ext(path)
310312
switch strings.ToLower(ext) {
@@ -322,9 +324,8 @@ func DecoderFromExtensionWithParams[T any](path string, p Params[T]) dials.Decod
322324
}
323325

324326
// FileExtensionDecoderConfigEnvFlag takes advantage of the
325-
// ConfigWithConfigPath cfg and thinly wraps ConfigFileEnvFlag and and thinly
326-
// wraps ConfigFileEnvFlag choosing the dials.Decoder used when handling the
327-
// file contents based on the file extension (from the limited set of JSON,
327+
// [ConfigWithConfigPath] cfg and thinly wraps [ConfigFileEnvFlag] choosing the [dials.Decoder] used
328+
// when handling the file contents based on the file extension (from the limited set of JSON,
328329
// Cue, YAML and TOML).
329330
func FileExtensionDecoderConfigEnvFlag[T any, TP ConfigWithConfigPath[T]](ctx context.Context, cfg TP, params Params[T]) (*dials.Dials[T], error) {
330331
return ConfigFileEnvFlagDecoderFactoryParams(ctx, cfg, DecoderFromExtensionWithParams[T], params)

0 commit comments

Comments
 (0)