From e7b01fdd1375fbd6ce742b1e3d77f3d6ddece127 Mon Sep 17 00:00:00 2001
From: chrisma <chrisma@tencent.com>
Date: Tue, 14 May 2024 09:03:54 +0800
Subject: [PATCH] rename options method
---
idiom/functional-options.md | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/idiom/functional-options.md b/idiom/functional-options.md
index 1e95086..7bf3508 100644
--- a/idiom/functional-options.md
+++ b/idiom/functional-options.md
@@ -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)
}