Commit 0c8968fb authored by Chris's avatar Chris Committed by Corey Hulen

unnamed return (#8170)

parent ac2e42a4
......@@ -74,41 +74,23 @@ func (me *AccessData) IsExpired() bool {
}
func (ad *AccessData) ToJson() string {
b, err := json.Marshal(ad)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(ad)
return string(b)
}
func AccessDataFromJson(data io.Reader) *AccessData {
decoder := json.NewDecoder(data)
var ad AccessData
err := decoder.Decode(&ad)
if err == nil {
return &ad
} else {
return nil
}
var ad *AccessData
json.NewDecoder(data).Decode(&ad)
return ad
}
func (ar *AccessResponse) ToJson() string {
b, err := json.Marshal(ar)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(ar)
return string(b)
}
func AccessResponseFromJson(data io.Reader) *AccessResponse {
decoder := json.NewDecoder(data)
var ar AccessResponse
err := decoder.Decode(&ar)
if err == nil {
return &ar
} else {
return nil
}
var ar *AccessResponse
json.NewDecoder(data).Decode(&ar)
return ar
}
......@@ -16,23 +16,14 @@ type AnalyticsRow struct {
type AnalyticsRows []*AnalyticsRow
func (me *AnalyticsRow) ToJson() string {
b, err := json.Marshal(me)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(me)
return string(b)
}
func AnalyticsRowFromJson(data io.Reader) *AnalyticsRow {
decoder := json.NewDecoder(data)
var me AnalyticsRow
err := decoder.Decode(&me)
if err == nil {
return &me
} else {
return nil
}
var me *AnalyticsRow
json.NewDecoder(data).Decode(&me)
return me
}
func (me AnalyticsRows) ToJson() string {
......@@ -44,12 +35,7 @@ func (me AnalyticsRows) ToJson() string {
}
func AnalyticsRowsFromJson(data io.Reader) AnalyticsRows {
decoder := json.NewDecoder(data)
var me AnalyticsRows
err := decoder.Decode(&me)
if err == nil {
return me
} else {
return nil
}
json.NewDecoder(data).Decode(&me)
return me
}
......@@ -19,21 +19,12 @@ type Audit struct {
}
func (o *Audit) ToJson() string {
b, err := json.Marshal(o)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(o)
return string(b)
}
func AuditFromJson(data io.Reader) *Audit {
decoder := json.NewDecoder(data)
var o Audit
err := decoder.Decode(&o)
if err == nil {
return &o
} else {
return nil
}
var o *Audit
json.NewDecoder(data).Decode(&o)
return o
}
......@@ -28,12 +28,7 @@ func (o Audits) ToJson() string {
}
func AuditsFromJson(data io.Reader) Audits {
decoder := json.NewDecoder(data)
var o Audits
err := decoder.Decode(&o)
if err == nil {
return o
} else {
return nil
}
json.NewDecoder(data).Decode(&o)
return o
}
......@@ -115,43 +115,25 @@ func (ad *AuthData) PreSave() {
}
func (ad *AuthData) ToJson() string {
b, err := json.Marshal(ad)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(ad)
return string(b)
}
func AuthDataFromJson(data io.Reader) *AuthData {
decoder := json.NewDecoder(data)
var ad AuthData
err := decoder.Decode(&ad)
if err == nil {
return &ad
} else {
return nil
}
var ad *AuthData
json.NewDecoder(data).Decode(&ad)
return ad
}
func (ar *AuthorizeRequest) ToJson() string {
b, err := json.Marshal(ar)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(ar)
return string(b)
}
func AuthorizeRequestFromJson(data io.Reader) *AuthorizeRequest {
decoder := json.NewDecoder(data)
var ar AuthorizeRequest
err := decoder.Decode(&ar)
if err == nil {
return &ar
} else {
return nil
}
var ar *AuthorizeRequest
json.NewDecoder(data).Decode(&ar)
return ar
}
func (ad *AuthData) IsExpired() bool {
......
......@@ -61,43 +61,25 @@ func (o *Channel) DeepCopy() *Channel {
}
func (o *Channel) ToJson() string {
b, err := json.Marshal(o)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(o)
return string(b)
}
func (o *ChannelPatch) ToJson() string {
b, err := json.Marshal(o)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(o)
return string(b)
}
func ChannelFromJson(data io.Reader) *Channel {
decoder := json.NewDecoder(data)
var o Channel
err := decoder.Decode(&o)
if err == nil {
return &o
} else {
return nil
}
var o *Channel
json.NewDecoder(data).Decode(&o)
return o
}
func ChannelPatchFromJson(data io.Reader) *ChannelPatch {
decoder := json.NewDecoder(data)
var o ChannelPatch
err := decoder.Decode(&o)
if err == nil {
return &o
} else {
return nil
}
var o *ChannelPatch
json.NewDecoder(data).Decode(&o)
return o
}
func (o *Channel) Etag() string {
......
......@@ -43,21 +43,12 @@ func (o *ChannelCounts) Etag() string {
}
func (o *ChannelCounts) ToJson() string {
b, err := json.Marshal(o)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(o)
return string(b)
}
func ChannelCountsFromJson(data io.Reader) *ChannelCounts {
decoder := json.NewDecoder(data)
var o ChannelCounts
err := decoder.Decode(&o)
if err == nil {
return &o
} else {
return nil
}
var o *ChannelCounts
json.NewDecoder(data).Decode(&o)
return o
}
......@@ -23,21 +23,12 @@ func (o *ChannelData) Etag() string {
}
func (o *ChannelData) ToJson() string {
b, err := json.Marshal(o)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(o)
return string(b)
}
func ChannelDataFromJson(data io.Reader) *ChannelData {
decoder := json.NewDecoder(data)
var o ChannelData
err := decoder.Decode(&o)
if err == nil {
return &o
} else {
return nil
}
var o *ChannelData
json.NewDecoder(data).Decode(&o)
return o
}
......@@ -41,23 +41,13 @@ func (o *ChannelList) Etag() string {
}
func ChannelListFromJson(data io.Reader) *ChannelList {
decoder := json.NewDecoder(data)
var o ChannelList
err := decoder.Decode(&o)
if err == nil {
return &o
} else {
return nil
}
var o *ChannelList
json.NewDecoder(data).Decode(&o)
return o
}
func ChannelSliceFromJson(data io.Reader) []*Channel {
decoder := json.NewDecoder(data)
var o []*Channel
err := decoder.Decode(&o)
if err == nil {
return o
} else {
return nil
}
json.NewDecoder(data).Decode(&o)
return o
}
......@@ -49,54 +49,31 @@ func (o *ChannelMembers) ToJson() string {
}
func (o *ChannelUnread) ToJson() string {
b, err := json.Marshal(o)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(o)
return string(b)
}
func ChannelMembersFromJson(data io.Reader) *ChannelMembers {
decoder := json.NewDecoder(data)
var o ChannelMembers
err := decoder.Decode(&o)
if err == nil {
return &o
} else {
return nil
}
var o *ChannelMembers
json.NewDecoder(data).Decode(&o)
return o
}
func ChannelUnreadFromJson(data io.Reader) *ChannelUnread {
decoder := json.NewDecoder(data)
var o ChannelUnread
err := decoder.Decode(&o)
if err == nil {
return &o
} else {
return nil
}
var o *ChannelUnread
json.NewDecoder(data).Decode(&o)
return o
}
func (o *ChannelMember) ToJson() string {
b, err := json.Marshal(o)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(o)
return string(b)
}
func ChannelMemberFromJson(data io.Reader) *ChannelMember {
decoder := json.NewDecoder(data)
var o ChannelMember
err := decoder.Decode(&o)
if err == nil {
return &o
} else {
return nil
}
var o *ChannelMember
json.NewDecoder(data).Decode(&o)
return o
}
func (o *ChannelMember) IsValid() *AppError {
......
......@@ -14,22 +14,13 @@ type ChannelSearch struct {
// ToJson convert a Channel to a json string
func (c *ChannelSearch) ToJson() string {
b, err := json.Marshal(c)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(c)
return string(b)
}
// ChannelSearchFromJson will decode the input and return a Channel
func ChannelSearchFromJson(data io.Reader) *ChannelSearch {
decoder := json.NewDecoder(data)
var cs ChannelSearch
err := decoder.Decode(&cs)
if err == nil {
return &cs
} else {
return nil
}
var cs *ChannelSearch
json.NewDecoder(data).Decode(&cs)
return cs
}
......@@ -14,21 +14,12 @@ type ChannelStats struct {
}
func (o *ChannelStats) ToJson() string {
b, err := json.Marshal(o)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(o)
return string(b)
}
func ChannelStatsFromJson(data io.Reader) *ChannelStats {
decoder := json.NewDecoder(data)
var o ChannelStats
err := decoder.Decode(&o)
if err == nil {
return &o
} else {
return nil
}
var o *ChannelStats
json.NewDecoder(data).Decode(&o)
return o
}
......@@ -14,23 +14,14 @@ type ChannelView struct {
}
func (o *ChannelView) ToJson() string {
b, err := json.Marshal(o)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(o)
return string(b)
}
func ChannelViewFromJson(data io.Reader) *ChannelView {
decoder := json.NewDecoder(data)
var o ChannelView
err := decoder.Decode(&o)
if err == nil {
return &o
} else {
return nil
}
var o *ChannelView
json.NewDecoder(data).Decode(&o)
return o
}
type ChannelViewResponse struct {
......@@ -39,21 +30,12 @@ type ChannelViewResponse struct {
}
func (o *ChannelViewResponse) ToJson() string {
b, err := json.Marshal(o)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(o)
return string(b)
}
func ChannelViewResponseFromJson(data io.Reader) *ChannelViewResponse {
decoder := json.NewDecoder(data)
var o ChannelViewResponse
err := decoder.Decode(&o)
if err == nil {
return &o
} else {
return nil
}
var o *ChannelViewResponse
json.NewDecoder(data).Decode(&o)
return o
}
......@@ -18,12 +18,8 @@ type ClusterInfo struct {
}
func (me *ClusterInfo) ToJson() string {
b, err := json.Marshal(me)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(me)
return string(b)
}
func (me *ClusterInfo) Copy() *ClusterInfo {
......@@ -32,22 +28,14 @@ func (me *ClusterInfo) Copy() *ClusterInfo {
}
func ClusterInfoFromJson(data io.Reader) *ClusterInfo {
decoder := json.NewDecoder(data)
var me ClusterInfo
err := decoder.Decode(&me)
if err == nil {
return &me
} else {
return nil
}
var me *ClusterInfo
json.NewDecoder(data).Decode(&me)
return me
}
func ClusterInfosToJson(objmap []*ClusterInfo) string {
if b, err := json.Marshal(objmap); err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(objmap)
return string(b)
}
func ClusterInfosFromJson(data io.Reader) []*ClusterInfo {
......
......@@ -28,5 +28,4 @@ func TestClusterInfosJson(t *testing.T) {
if clusterInfos[0].IpAddress != result[0].IpAddress {
t.Fatal("Ids do not match")
}
}
......@@ -35,21 +35,12 @@ type ClusterMessage struct {
}
func (o *ClusterMessage) ToJson() string {
b, err := json.Marshal(o)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(o)
return string(b)
}
func ClusterMessageFromJson(data io.Reader) *ClusterMessage {
decoder := json.NewDecoder(data)
var o ClusterMessage
err := decoder.Decode(&o)
if err == nil {
return &o
} else {
return nil
}
var o *ClusterMessage
json.NewDecoder(data).Decode(&o)
return o
}
......@@ -16,21 +16,12 @@ type ClusterStats struct {
}
func (me *ClusterStats) ToJson() string {
b, err := json.Marshal(me)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(me)
return string(b)
}
func ClusterStatsFromJson(data io.Reader) *ClusterStats {
decoder := json.NewDecoder(data)
var me ClusterStats
err := decoder.Decode(&me)
if err == nil {
return &me
} else {
return nil
}
var me *ClusterStats
json.NewDecoder(data).Decode(&me)
return me
}
......@@ -38,43 +38,25 @@ type Command struct {
}
func (o *Command) ToJson() string {
b, err := json.Marshal(o)
if err != nil {
return ""
} else {
return string(b)
}
b, _ := json.Marshal(o)
return string(b)
}
func CommandFromJson(data io.Reader) *Command {
decoder := json.NewDecoder(data)
var o Command