-
-
Notifications
You must be signed in to change notification settings - Fork 302
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
Feature/#106 fmt function #151
Feature/#106 fmt function #151
Conversation
…ature/#106_fmt_function
…ature/#106_fmt_function
…ature/#106_fmt_function
pkg/stdlib/strings/fmt.go
Outdated
return values.NewString(formatted), nil | ||
} | ||
|
||
func format(template string, args ...core.Value) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change args ...core.Value
to args []core.Value
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. But what's the difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because variadic functions create a new slice. Extra unnecessary work.
pkg/stdlib/strings/fmt.go
Outdated
func format(template string, args ...core.Value) (string, error) { | ||
rgx, err := regexp.Compile("{[0-9]*}") | ||
if err != nil { | ||
return "", fmt.Errorf("failed to build regexp: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's be consistent in terms of errors. Could you use https://github.com/pkg/errors
instead of fmt
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but needs some minor changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Great job! Thank you for your time and efforts! |
Closes #106 |
No description provided.