fix errcheck warnings (#1739)
This commit is contained in:
committed by
thinkerou
parent
29a145c85d
commit
b056a34bdc
+5
-5
@@ -20,8 +20,7 @@ var plainContentType = []string{"text/plain; charset=utf-8"}
|
||||
|
||||
// Render (String) writes data with custom ContentType.
|
||||
func (r String) Render(w http.ResponseWriter) error {
|
||||
WriteString(w, r.Format, r.Data)
|
||||
return nil
|
||||
return WriteString(w, r.Format, r.Data)
|
||||
}
|
||||
|
||||
// WriteContentType (String) writes Plain ContentType.
|
||||
@@ -30,11 +29,12 @@ func (r String) WriteContentType(w http.ResponseWriter) {
|
||||
}
|
||||
|
||||
// WriteString writes data according to its format and write custom ContentType.
|
||||
func WriteString(w http.ResponseWriter, format string, data []interface{}) {
|
||||
func WriteString(w http.ResponseWriter, format string, data []interface{}) (err error) {
|
||||
writeContentType(w, plainContentType)
|
||||
if len(data) > 0 {
|
||||
fmt.Fprintf(w, format, data...)
|
||||
_, err = fmt.Fprintf(w, format, data...)
|
||||
return
|
||||
}
|
||||
io.WriteString(w, format)
|
||||
_, err = io.WriteString(w, format)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user