2
0

MarshalJSON should be defined on T not *T

Otherwise "%v" format would be used by json.Marshal(T).
This commit is contained in:
Jack Christensen
2019-08-27 21:13:45 -05:00
parent 432c2951c7
commit 76538434cf
34 changed files with 34 additions and 34 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ func (src *BackendKeyData) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *BackendKeyData) MarshalJSON() ([]byte, error) { func (src BackendKeyData) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
ProcessID uint32 ProcessID uint32
+1 -1
View File
@@ -144,7 +144,7 @@ func (src *Bind) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *Bind) MarshalJSON() ([]byte, error) { func (src Bind) MarshalJSON() ([]byte, error) {
formattedParameters := make([]map[string]string, len(src.Parameters)) formattedParameters := make([]map[string]string, len(src.Parameters))
for i, p := range src.Parameters { for i, p := range src.Parameters {
if p == nil { if p == nil {
+1 -1
View File
@@ -25,7 +25,7 @@ func (src *BindComplete) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *BindComplete) MarshalJSON() ([]byte, error) { func (src BindComplete) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
}{ }{
+1 -1
View File
@@ -51,7 +51,7 @@ func (src *Close) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *Close) MarshalJSON() ([]byte, error) { func (src Close) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
ObjectType string ObjectType string
+1 -1
View File
@@ -25,7 +25,7 @@ func (src *CloseComplete) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *CloseComplete) MarshalJSON() ([]byte, error) { func (src CloseComplete) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
}{ }{
+1 -1
View File
@@ -42,7 +42,7 @@ func (src *CommandComplete) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *CommandComplete) MarshalJSON() ([]byte, error) { func (src CommandComplete) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
CommandTag string CommandTag string
+1 -1
View File
@@ -59,7 +59,7 @@ func (src *CopyBothResponse) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *CopyBothResponse) MarshalJSON() ([]byte, error) { func (src CopyBothResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
ColumnFormatCodes []uint16 ColumnFormatCodes []uint16
+1 -1
View File
@@ -33,7 +33,7 @@ func (src *CopyData) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *CopyData) MarshalJSON() ([]byte, error) { func (src CopyData) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
Data string Data string
+1 -1
View File
@@ -26,7 +26,7 @@ func (src *CopyDone) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *CopyDone) MarshalJSON() ([]byte, error) { func (src CopyDone) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
}{ }{
+1 -1
View File
@@ -42,7 +42,7 @@ func (src *CopyFail) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *CopyFail) MarshalJSON() ([]byte, error) { func (src CopyFail) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
Message string Message string
+1 -1
View File
@@ -59,7 +59,7 @@ func (src *CopyInResponse) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *CopyInResponse) MarshalJSON() ([]byte, error) { func (src CopyInResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
ColumnFormatCodes []uint16 ColumnFormatCodes []uint16
+1 -1
View File
@@ -60,7 +60,7 @@ func (src *CopyOutResponse) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *CopyOutResponse) MarshalJSON() ([]byte, error) { func (src CopyOutResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
ColumnFormatCodes []uint16 ColumnFormatCodes []uint16
+1 -1
View File
@@ -85,7 +85,7 @@ func (src *DataRow) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *DataRow) MarshalJSON() ([]byte, error) { func (src DataRow) MarshalJSON() ([]byte, error) {
formattedValues := make([]map[string]string, len(src.Values)) formattedValues := make([]map[string]string, len(src.Values))
for i, v := range src.Values { for i, v := range src.Values {
if v == nil { if v == nil {
+1 -1
View File
@@ -51,7 +51,7 @@ func (src *Describe) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *Describe) MarshalJSON() ([]byte, error) { func (src Describe) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
ObjectType string ObjectType string
+1 -1
View File
@@ -25,7 +25,7 @@ func (src *EmptyQueryResponse) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *EmptyQueryResponse) MarshalJSON() ([]byte, error) { func (src EmptyQueryResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
}{ }{
+1 -1
View File
@@ -52,7 +52,7 @@ func (src *Execute) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *Execute) MarshalJSON() ([]byte, error) { func (src Execute) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
Portal string Portal string
+1 -1
View File
@@ -25,7 +25,7 @@ func (src *Flush) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *Flush) MarshalJSON() ([]byte, error) { func (src Flush) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
}{ }{
+1 -1
View File
@@ -57,7 +57,7 @@ func (src *FunctionCallResponse) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *FunctionCallResponse) MarshalJSON() ([]byte, error) { func (src FunctionCallResponse) MarshalJSON() ([]byte, error) {
var formattedValue map[string]string var formattedValue map[string]string
var hasNonPrintable bool var hasNonPrintable bool
for _, b := range src.Result { for _, b := range src.Result {
+1 -1
View File
@@ -25,7 +25,7 @@ func (src *NoData) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *NoData) MarshalJSON() ([]byte, error) { func (src NoData) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
}{ }{
+1 -1
View File
@@ -57,7 +57,7 @@ func (src *NotificationResponse) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *NotificationResponse) MarshalJSON() ([]byte, error) { func (src NotificationResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
PID uint32 PID uint32
+1 -1
View File
@@ -55,7 +55,7 @@ func (src *ParameterDescription) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *ParameterDescription) MarshalJSON() ([]byte, error) { func (src ParameterDescription) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
ParameterOIDs []uint32 ParameterOIDs []uint32
+1 -1
View File
@@ -53,7 +53,7 @@ func (src *ParameterStatus) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (ps *ParameterStatus) MarshalJSON() ([]byte, error) { func (ps ParameterStatus) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
Name string Name string
+1 -1
View File
@@ -73,7 +73,7 @@ func (src *Parse) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *Parse) MarshalJSON() ([]byte, error) { func (src Parse) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
Name string Name string
+1 -1
View File
@@ -25,7 +25,7 @@ func (src *ParseComplete) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *ParseComplete) MarshalJSON() ([]byte, error) { func (src ParseComplete) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
}{ }{
+1 -1
View File
@@ -40,7 +40,7 @@ func (src *PasswordMessage) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *PasswordMessage) MarshalJSON() ([]byte, error) { func (src PasswordMessage) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
Password string Password string
+1 -1
View File
@@ -25,7 +25,7 @@ func (src *PortalSuspended) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *PortalSuspended) MarshalJSON() ([]byte, error) { func (src PortalSuspended) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
}{ }{
+1 -1
View File
@@ -39,7 +39,7 @@ func (src *Query) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *Query) MarshalJSON() ([]byte, error) { func (src Query) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
String string String string
+1 -1
View File
@@ -29,7 +29,7 @@ func (src *ReadyForQuery) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *ReadyForQuery) MarshalJSON() ([]byte, error) { func (src ReadyForQuery) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
TxStatus string TxStatus string
+1 -1
View File
@@ -102,7 +102,7 @@ func (src *RowDescription) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *RowDescription) MarshalJSON() ([]byte, error) { func (src RowDescription) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
Fields []FieldDescription Fields []FieldDescription
+1 -1
View File
@@ -56,7 +56,7 @@ func (src *SASLInitialResponse) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *SASLInitialResponse) MarshalJSON() ([]byte, error) { func (src SASLInitialResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
AuthMechanism string AuthMechanism string
+1 -1
View File
@@ -32,7 +32,7 @@ func (src *SASLResponse) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *SASLResponse) MarshalJSON() ([]byte, error) { func (src SASLResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
Data string Data string
+1 -1
View File
@@ -89,7 +89,7 @@ func (src *StartupMessage) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *StartupMessage) MarshalJSON() ([]byte, error) { func (src StartupMessage) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
ProtocolVersion uint32 ProtocolVersion uint32
+1 -1
View File
@@ -25,7 +25,7 @@ func (src *Sync) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *Sync) MarshalJSON() ([]byte, error) { func (src Sync) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
}{ }{
+1 -1
View File
@@ -25,7 +25,7 @@ func (src *Terminate) Encode(dst []byte) []byte {
} }
// MarshalJSON implements encoding/json.Marshaler. // MarshalJSON implements encoding/json.Marshaler.
func (src *Terminate) MarshalJSON() ([]byte, error) { func (src Terminate) MarshalJSON() ([]byte, error) {
return json.Marshal(struct { return json.Marshal(struct {
Type string Type string
}{ }{