diff options
author | George Goldberg <george@gberg.me> | 2018-02-06 17:25:53 +0000 |
---|---|---|
committer | George Goldberg <george@gberg.me> | 2018-02-06 17:25:53 +0000 |
commit | 7941c30117efe1b957ac0458c2f0479e3824196d (patch) | |
tree | df791632a9dc790a6f73dec53aae3ba919ebda63 /model/utils.go | |
parent | e1cd64613591cf5a990442a69ebf188258bd0cb5 (diff) | |
parent | 034dbc07e3068c482e654b6a1a8fcbe4b01c44f3 (diff) | |
download | chat-7941c30117efe1b957ac0458c2f0479e3824196d.tar.gz chat-7941c30117efe1b957ac0458c2f0479e3824196d.tar.bz2 chat-7941c30117efe1b957ac0458c2f0479e3824196d.zip |
Merge branch 'master' into advanced-permissions-phase-1
Diffstat (limited to 'model/utils.go')
-rw-r--r-- | model/utils.go | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/model/utils.go b/model/utils.go index 648e67c75..331a1aaaa 100644 --- a/model/utils.go +++ b/model/utils.go @@ -79,12 +79,8 @@ func (er *AppError) SystemMessage(T goi18n.TranslateFunc) string { } func (er *AppError) ToJson() string { - b, err := json.Marshal(er) - if err != nil { - return "" - } else { - return string(b) - } + b, _ := json.Marshal(er) + return string(b) } // AppErrorFromJson will decode the input and return an AppError @@ -152,20 +148,14 @@ func GetMillis() int64 { // MapToJson converts a map to a json string func MapToJson(objmap map[string]string) string { - if b, err := json.Marshal(objmap); err != nil { - return "" - } else { - return string(b) - } + b, _ := json.Marshal(objmap) + return string(b) } // MapToJson converts a map to a json string func MapBoolToJson(objmap map[string]bool) string { - if b, err := json.Marshal(objmap); err != nil { - return "" - } else { - return string(b) - } + b, _ := json.Marshal(objmap) + return string(b) } // MapFromJson will decode the key/value pair map @@ -193,11 +183,8 @@ func MapBoolFromJson(data io.Reader) map[string]bool { } func ArrayToJson(objmap []string) string { - if b, err := json.Marshal(objmap); err != nil { - return "" - } else { - return string(b) - } + b, _ := json.Marshal(objmap) + return string(b) } func ArrayFromJson(data io.Reader) []string { @@ -229,11 +216,8 @@ func ArrayFromInterface(data interface{}) []string { } func StringInterfaceToJson(objmap map[string]interface{}) string { - if b, err := json.Marshal(objmap); err != nil { - return "" - } else { - return string(b) - } + b, _ := json.Marshal(objmap) + return string(b) } func StringInterfaceFromJson(data io.Reader) map[string]interface{} { @@ -248,12 +232,8 @@ func StringInterfaceFromJson(data io.Reader) map[string]interface{} { } func StringToJson(s string) string { - b, err := json.Marshal(s) - if err != nil { - return "" - } else { - return string(b) - } + b, _ := json.Marshal(s) + return string(b) } func StringFromJson(data io.Reader) string { |