API not idiomatic
Get* functions are not idiomatic in Go.
What about something like https://golang.org/pkg/net/http/#Header?
See https://golang.org/doc/effective_go.html#Getters
(For http.Header the Get function returns the field given as param so it's okay)
Ok, so then that would imply a change to the read adapters' signatures. Something along the lines of:
type identityReadAdapter interface {
ID() (string, error)
Type() (string, error)
}
type attributesReadAdapter interface {
Attributes() (map[string]interface{}, error)
}
...etc
It doesn't seem like implementing any of those methods would conflict with other packages. The only real issue I have here is that they aren't true getters since they return a value/error pair, so is it even appropriate to consider them under this idiom?
Also I'd think to leave the jsonapi.Links and jsonapi.Relationships signatures unchanged since they work in a similar way as http.Header.
Why do these functions return an error in the first place?
Because errors can occur while converting data to/from the resource. For a concrete example, consider that the specification states that a resource id member must be of type string. However, it is not uncommon to use an integer to identify an object on the backend. In order to avoid ignoring errors in cases like this (for instance, calling something like strconv.ParseInt), all read adapter implementations should return a value/error pair and all write adapter implementations should return an error.