1
0
mirror of https://github.com/tmrts/go-patterns.git synced 2024-11-21 20:46:08 +03:00

rename options method

This commit is contained in:
chrisma 2024-05-14 09:03:54 +08:00
parent f978e42036
commit e7b01fdd13

View File

@ -20,25 +20,25 @@ type Options struct {
type Option func(*Options)
func UID(userID int) Option {
func WithUID(userID int) Option {
return func(args *Options) {
args.UID = userID
}
}
func GID(groupID int) Option {
func WithGID(groupID int) Option {
return func(args *Options) {
args.GID = groupID
}
}
func Contents(c string) Option {
func WithContents(c string) Option {
return func(args *Options) {
args.Contents = c
}
}
func Permissions(perms os.FileMode) Option {
func WithPermissions(perms os.FileMode) Option {
return func(args *Options) {
args.Permissions = perms
}
@ -87,7 +87,7 @@ if err != nil {
panic(err)
}
fillerFile, err := file.New("/tmp/file.txt", file.UID(1000), file.Contents("Lorem Ipsum Dolor Amet"))
fillerFile, err := file.New("/tmp/file.txt", file.WithUID(1000), file.WithContents("Lorem Ipsum Dolor Amet"))
if err != nil {
panic(err)
}