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

Use pointer Valuer to fix nil pointer issue #28

Closed
blockloop opened this issue Jul 5, 2016 · 1 comment
Closed

Use pointer Valuer to fix nil pointer issue #28

blockloop opened this issue Jul 5, 2016 · 1 comment

Comments

@blockloop
Copy link

type Opportunity struct {
    ID                  *int       `db:"OpportunityId,omitempty"`
    GlobalOpportunityID *uuid.UUID `db:"GlobalOpportunityId,omitempty"`
}

I am using a this struct and when I call database actions I'm running into golang/go#8415 because go is calling Value() even though the pointer is nil. This is something they appear to be fixing in a later version, but their suggestion is to put a Valuer on *UUID instead of UUID. I changed the sql.go Value() method in my vendor folder to use a pointer and the issue went away.

Does this create any problems that I'm missing?

@blockloop
Copy link
Author

Scratch this. By creating the Value() method for *UUID you can no longer use UUID without a pointer.

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

1 participant