💡 Improve go doc comments with internal links

This commit is contained in:
Dan Jones 2025-03-31 12:10:05 -05:00
commit c5a9f09166
8 changed files with 38 additions and 34 deletions

View file

@ -10,25 +10,25 @@ import (
// for example.
type Generator func(conf *Config) (string, error)
// Make allows you to generate a new string directly from a Generator.
// Make allows you to generate a new string directly from a [Generator].
func (g Generator) Make(opts ...Option) (string, error) {
return g.MakeWithConfig(NewConfig(opts...))
}
// MakeWithConfig allows you to generate a new string directly from a Generator
// MakeWithConfig allows you to generate a new string directly from a [Generator]
// with a pre-existing Config.
func (g Generator) MakeWithConfig(c Config) (string, error) {
return Make(c.AddOptions(WithGenerator(g)))
}
// WithGenerator sets the specified generator.
// WithGenerator sets the specified [Generator].
func WithGenerator(g Generator) Option {
return func(c *Config) {
c.generator = g
}
}
// ErrMissingGenerators is returned by a multi-generator if no generators are supplied.
// ErrMissingGenerators is returned by a multi-generator if no [Generator]s are supplied.
var ErrMissingGenerators = errors.New("no generators supplied")
func missingGen(*Config) (string, error) {
@ -36,7 +36,7 @@ func missingGen(*Config) (string, error) {
}
// MultiGeneratorInOrder allows the use of multiple generators. Each new invokation will use the next generator in turn.
// If none are passed, the generator will always return ErrMissingGenerators.
// If none are passed, the generator will always return [ErrMissingGenerators].
func MultiGeneratorInOrder(gens ...Generator) Generator {
if len(gens) == 0 {
return missingGen
@ -55,7 +55,7 @@ func MultiGeneratorInOrder(gens ...Generator) Generator {
}
// MultiGeneratorRandomOrder allows the use of multiple generators. Each new invokation will use one of the generators randomly.
// If none are passed, the generator will always return ErrMissingGenerators.
// If none are passed, the generator will always return [ErrMissingGenerators].
func MultiGeneratorRandomOrder(gens ...Generator) Generator {
if len(gens) == 0 {
return missingGen