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

string in StringFrom #18

Closed
vpol opened this issue Jun 3, 2016 · 1 comment
Closed

string in StringFrom #18

vpol opened this issue Jun 3, 2016 · 1 comment

Comments

@vpol
Copy link

vpol commented Jun 3, 2016

Can we make StringFrom verify string argument for "emptiness"?

func StringFrom(s string) String {
    return NewString(s, true)
}

to

func StringFrom(s string) String {
        if s == "" {
            return NewString(s, false)
        }
        return NewString(s, true)
}

It is useful in:

result := null.StringFrom(ctx.Request.Header.Get("some-header"))

And many other cases.

Or a new method with this behaviour?

@guregu
Copy link
Owner

guregu commented Jun 6, 2016

Hello, you can use zero.String, which works like that. If you don't want the other behavior the zero package specifies, I'd recommend forking this package and making the changes there.

@guregu guregu closed this as completed Apr 5, 2017
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

No branches or pull requests

2 participants