refactor(backend): Use more efficient bytes to string methods and remove unnecessary type conversions

detail:
    1. add utils.BytesToString function instead of string() convert bytes to string.
    2. use bytes.NewReader instead of strings.NewReader(string(sb)).
    3. use w.Body.Bytes() instead of []byte(w.Body.String()).
This commit is contained in:
yaziming
2019-09-03 01:07:59 +08:00
committed by yaziming
parent cb3d7263b2
commit e10d8fd996
17 changed files with 81 additions and 63 deletions

7
backend/utils/helpers.go Normal file
View File

@@ -0,0 +1,7 @@
package utils
import "unsafe"
func BytesToString(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
}