mirror of
https://github.com/jimeh/go-golden.git
synced 2026-02-19 03:16:38 +00:00
Enables simpler creation of custom *Golden instances, as you can just pass in the custom values to New(), rather than modifying fields after increating the Golden instance.
44 lines
915 B
Go
44 lines
915 B
Go
package golden
|
|
|
|
import (
|
|
"os"
|
|
)
|
|
|
|
// Option is a function that modifies a Golden instance.
|
|
type Option func(*Golden)
|
|
|
|
// WithDirMode sets the directory mode for a Golden instance.
|
|
func WithDirMode(mode os.FileMode) Option {
|
|
return func(g *Golden) {
|
|
g.DirMode = mode
|
|
}
|
|
}
|
|
|
|
// WithFileMode sets the file mode for a Golden instance.
|
|
func WithFileMode(mode os.FileMode) Option {
|
|
return func(g *Golden) {
|
|
g.FileMode = mode
|
|
}
|
|
}
|
|
|
|
// WithSuffix sets the file suffix for a Golden instance.
|
|
func WithSuffix(suffix string) Option {
|
|
return func(g *Golden) {
|
|
g.Suffix = suffix
|
|
}
|
|
}
|
|
|
|
// WithDirname sets the directory name for a Golden instance.
|
|
func WithDirname(dirname string) Option {
|
|
return func(g *Golden) {
|
|
g.Dirname = dirname
|
|
}
|
|
}
|
|
|
|
// WithUpdateFunc sets the update function for a Golden instance.
|
|
func WithUpdateFunc(updateFunc UpdateFunc) Option {
|
|
return func(g *Golden) {
|
|
g.UpdateFunc = updateFunc
|
|
}
|
|
}
|