From 04bf04450b8c014e6d3846a2ba544082e77d4156 Mon Sep 17 00:00:00 2001 From: Sharon Lourduraj Date: Thu, 7 Jan 2016 15:14:57 -0500 Subject: [PATCH] Added support for int64 and uint64 primary id types --- response.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/response.go b/response.go index 5c1593e..ca735f1 100644 --- a/response.go +++ b/response.go @@ -178,17 +178,18 @@ func visitModelNode(model interface{}, included *map[string]*Node, sideload bool if annotation == "primary" { id := fieldValue.Interface() - str, ok := id.(string) - if ok { - node.Id = str - } else { - j, ok := id.(int) - if ok { - node.Id = strconv.Itoa(j) - } else { - er = ErrBadJSONAPIID - break - } + switch nId := id.(type) { + case string: + node.Id = nId + case int: + node.Id = strconv.Itoa(nId) + case int64: + node.Id = strconv.FormatInt(nId, 10) + case uint64: + node.Id = strconv.FormatUint(nId, 10) + default: + er = ErrBadJSONAPIID + break } node.Type = args[1]