Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(binding): add BindPlain #3904

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions binding/binding_nomsgpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ var (
Uri = uriBinding{}
Header = headerBinding{}
TOML = tomlBinding{}
Plain = plainBinding{}
)

// Default returns the appropriate Binding instance based on the HTTP method
Expand Down
6 changes: 3 additions & 3 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ func (c *Context) SaveUploadedFile(file *multipart.FileHeader, dst string) error
}
defer src.Close()

if err = os.MkdirAll(filepath.Dir(dst), 0750); err != nil {
if err = os.MkdirAll(filepath.Dir(dst), 0o750); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution should be exercised regarding permission modifications to files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines of code are actually the same, except for the representation of file permissions using different formats for octal notation.

In the first line, the file permissions are represented using octal notation, specifically 0750. In octal notation, a number starting with 0 denotes that it's an octal number. Therefore, 0750 represents permissions set to rwxr-x--- (i.e., the owner has read, write, and execute permissions, the group users have read and execute permissions, and others have no permissions).

In the second line, the new octal literal notation is used, denoted by 0o750. In this notation, numbers start with 0o to indicate octal representation. So, 0o750 also represents permissions set to rwxr-x---.

In summary, these two lines of code are entirely equivalent; they just use different formats for representing permissions when using octal notation.

return err
}

Expand Down Expand Up @@ -668,7 +668,7 @@ func (c *Context) BindTOML(obj any) error {
}

// BindPlain is a shortcut for c.MustBindWith(obj, binding.Plain).
func (c *Context) BindPlain(obj interface{}) error {
func (c *Context) BindPlain(obj any) error {
return c.MustBindWith(obj, binding.Plain)
}

Expand Down Expand Up @@ -738,7 +738,7 @@ func (c *Context) ShouldBindTOML(obj any) error {
}

// ShouldBindPlain is a shortcut for c.ShouldBindWith(obj, binding.Plain).
func (c *Context) ShouldBindPlain(obj interface{}) error {
func (c *Context) ShouldBindPlain(obj any) error {
return c.ShouldBindWith(obj, binding.Plain)
}

Expand Down