Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions idiom/functional-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,36 @@ Options implemented as a function set the state of that option.
```go
package file

type Options struct {
type options struct {
UID int
GID int
Flags int
Contents string
Permissions os.FileMode
}

type Option func(*Options)
type Option func(*options)

func UID(userID int) Option {
return func(args *Options) {
return func(args *options) {
args.UID = userID
}
}

func GID(groupID int) Option {
return func(args *Options) {
return func(args *options) {
args.GID = groupID
}
}

func Contents(c string) Option {
return func(args *Options) {
return func(args *options) {
args.Contents = c
}
}

func Permissions(perms os.FileMode) Option {
return func(args *Options) {
return func(args *options) {
args.Permissions = perms
}
}
Expand All @@ -51,8 +51,8 @@ func Permissions(perms os.FileMode) Option {
package file

func New(filepath string, setters ...Option) error {
// Default Options
args := &Options{
// Default options
args := &options{
UID: os.Getuid(),
GID: os.Getgid(),
Contents: "",
Expand Down