diff --git a/tx0/message/message_event_response.go b/tx0/message/message_event_response.go index 142bb94..c1cae36 100644 --- a/tx0/message/message_event_response.go +++ b/tx0/message/message_event_response.go @@ -9,9 +9,9 @@ import ( ) type MessageEventResponse struct { - Id uuid.UUID `json:"id,omitempty"` - ScheduledMessageEventId uuid.UUID `json:"scheduled_message_event_id,omitempty"` - Response types.JSONB `json:"response"` - UserId uuid.UUID `json:"user_id,omitempty"` - Sent time.Time `json:"sent"` + Id uuid.UUID `json:"id,omitempty"` + ScheduledMessageEventId uuid.UUID `json:"scheduled_message_event_id,omitempty"` + Response types.JSONB `json:"response"` + UserId uuid.UUID `json:"user_id,omitempty"` + Sent time.Time `json:"sent"` } diff --git a/tx0/types/jsonb.go b/tx0/types/jsonb.go index 1c45023..9bacec6 100644 --- a/tx0/types/jsonb.go +++ b/tx0/types/jsonb.go @@ -6,37 +6,36 @@ import ( "fmt" ) - type JSONB json.RawMessage // Scan implements sql.Scanner func (j *JSONB) Scan(value interface{}) error { - if value == nil { - *j = nil - return nil - } - - var data []byte - switch v := value.(type) { - case []byte: - // pgx may pass data as []byte in binary format - data = v - case string: - // pgx may pass data as string in text format - data = []byte(v) - default: - return fmt.Errorf("unsupported type: %T", v) - } - - *j = JSONB(data) - return nil + if value == nil { + *j = nil + return nil + } + + var data []byte + switch v := value.(type) { + case []byte: + // pgx may pass data as []byte in binary format + data = v + case string: + // pgx may pass data as string in text format + data = []byte(v) + default: + return fmt.Errorf("unsupported type: %T", v) + } + + *j = JSONB(data) + return nil } // Value implements driver.Valuer func (j JSONB) Value() (driver.Value, error) { - if j == nil { - return nil, nil - } else { - return []byte(j), nil - } + if j == nil { + return nil, nil + } else { + return []byte(j), nil + } }