Thank you @Michel. Disturbing that I keep making the same mistake again...
On Monday, March 15, 2021 at 2:05:53 PM UTC+1 mlevi...@gmail.com wrote:
> This is because per the Go spec:
> https://golang.org/ref/spec#Type_declarations
> You're not creating an alias to Token, but defining a new type
On Mon, Mar 15, 2021 at 1:49 PM cpu...@gmail.com wrote:
> type WrappedToken Token
Note that this is not a type alias. WrappedToken is a new type. Even
if its underlying type is Token, WrappedToken does not automatically
have any methods of Token.
> Only to find out, that unmarshaling a
This is because per the Go spec:
https://golang.org/ref/spec#Type_declarations
You're not creating an alias to Token, but defining a new type from it. If
what you are looking for is an alias (meaning to have the "WrappedToken"
identifier refer to the exact same type as Token), you need to do:
I've just tried doing something like this in my code:
// Token is an OAuth2 token which includes decoding the expires_in attribute
type Token struct {
oauth2.Token
ExpiresIn int `json:"expires_in"` // expiration time in seconds
}
func (t *Token) UnmarshalJSON(data []byte) error {
...
}
type