Closed
Description
I am trying to get github user repositories
https://gist.github.com/yisiper/48ea8ddc9c48d97e7a9f
Not all repositories return it's language , the return json may just {language : null}, thus the pointer in struct point to nil.
it need to do many pointer nil checking before use those field.
Is it possible to let the default type initialized?
says string should be "", int should be 0.
ref: #19 (comment)
Activity
rsc commentedon Apr 9, 2015
I use helpers like this in my own code using this package:
Then if you don't care about present vs not present, you can use, say, getString(issue.Xxx) instead of checking whether issue.Xxx is nil.
willnorris commentedon Apr 28, 2015
Unfortunately, there's not an easy solution to this. #19 certainly does have all the discussion that led to this design, but I also wrote about it here if you're interested.
The best solution will be to implement #45, which is what the proto library does.
go generate
didn't exist when I originally filed that issue, so it would actually be much easier to implement now.Closing this for now, as there isn't actually anything to do here.