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

deprecate panicking functions #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ludusrusso
Copy link

This PR solves #24

If you are ok with my proposal I can updates internal code and example to use the new function

object.go Outdated
@@ -232,6 +232,7 @@ func (obj *Object) GetInt64(attr string) (int64, error) {
}

// MustGetInt64 is like GetInt64, but it panic in case of error.
// Deprecated: use GetInt64 instead
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't deprecate these functions. Similar to regexp.MustCompile for example.
https://www.journal.petrausch.info/post/2020/05/must-pattern/

Copy link
Author

Choose a reason for hiding this comment

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

Didn't know this pattern, I like it in any case.

So what do you think about leave as is of Must* functions, deprecating URL function (it is not clear that can panic) and create a new MustURL function (or similar) to handle scenarios like

		if _, err := s.cli.GetData(MustURL("monitor/items/upload_url"), &u); err != nil {

Copy link
Member

@joseotoro joseotoro left a comment

Choose a reason for hiding this comment

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

LGTM

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