timehop / apns

A Go package to interface with the Apple Push Notification Service
https://godoc.org/github.com/timehop/apns
MIT License
185 stars 47 forks source link

Badge field being `*int` breaks int assignment in go1.4 #18

Closed chakrit closed 9 years ago

chakrit commented 9 years ago

This line: https://github.com/timehop/apns/blob/master/notification.go#L50

Since it is a *int you can no longer assign int to it directly. This is probably due to the pointer handling changes in the recently released go1.4.

I think the docs needs updating to reflect this.

chakrit commented 9 years ago

Also you can't take the address of int literals directly.

All of the following lines fails to compile in go1.4:

var x *int = 4   // cannot use 4 (type int) as type *int in assignment
x = &5           // cannot take the address of 5

So direct assignment as example in the docs is now impossible. I have to put it in a temporary variable first and take that var's address which is kinda cumbersome actually.

nathany commented 9 years ago

@chakrit This isn't specific to Go 1.4.

It is a breaking change in timehop/apns. Sorry about that :frowning:

The reason badge is now a pointer is because badge=0 and not sending badge have different behaviours on Apple's side. See #15.

The docs/example do need to be updated.

taylortrimble commented 9 years ago

Luckily I think the direct assignment case is going to be rare by the nature of the badge. Anyone want to volunteer to do the docs? Otherwise, assign me and I'll do it "sometime".

nathany commented 9 years ago

The example was updated in 4274e69b3a28afa3f7627f58f08619729bf82278 but the README still needs updating.

chakrit commented 9 years ago

Thanks for clarifying.

I can help over the weekends if I dont forget it by then :p