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

Feature/#106 fmt function #151

Merged
merged 8 commits into from
Oct 29, 2018

Conversation

3timeslazy
Copy link
Member

No description provided.

return values.NewString(formatted), nil
}

func format(template string, args ...core.Value) (string, error) {
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

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.

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)
Copy link
Member

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?

Copy link
Member

@ziflex ziflex left a 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.

Copy link
Member

@ziflex ziflex left a comment

Choose a reason for hiding this comment

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

Looks good!

@ziflex ziflex merged commit f6e465d into MontFerret:master Oct 29, 2018
@ziflex
Copy link
Member

ziflex commented Oct 29, 2018

Great job! Thank you for your time and efforts!

@ziflex
Copy link
Member

ziflex commented Oct 29, 2018

Closes #106

@3timeslazy 3timeslazy deleted the feature/#106_fmt_function branch November 2, 2018 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants