diff --git a/container/gmap/gmap_hash_any_any_map.go b/container/gmap/gmap_hash_any_any_map.go index a42cf26ea..3544d0648 100644 --- a/container/gmap/gmap_hash_any_any_map.go +++ b/container/gmap/gmap_hash_any_any_map.go @@ -460,7 +460,7 @@ func (m *AnyAnyMap) Merge(other *AnyAnyMap) { // String returns the map as a string. func (m *AnyAnyMap) String() string { b, _ := m.MarshalJSON() - return gconv.UnsafeBytesToStr(b) + return string(b) } // MarshalJSON implements the interface MarshalJSON for json.Marshal. diff --git a/container/gmap/gmap_hash_int_any_map.go b/container/gmap/gmap_hash_int_any_map.go index f99fd77d4..5ced8024f 100644 --- a/container/gmap/gmap_hash_int_any_map.go +++ b/container/gmap/gmap_hash_int_any_map.go @@ -458,7 +458,7 @@ func (m *IntAnyMap) Merge(other *IntAnyMap) { // String returns the map as a string. func (m *IntAnyMap) String() string { b, _ := m.MarshalJSON() - return gconv.UnsafeBytesToStr(b) + return string(b) } // MarshalJSON implements the interface MarshalJSON for json.Marshal. diff --git a/container/gmap/gmap_hash_int_int_map.go b/container/gmap/gmap_hash_int_int_map.go index 3f8b8d411..5ca359630 100644 --- a/container/gmap/gmap_hash_int_int_map.go +++ b/container/gmap/gmap_hash_int_int_map.go @@ -429,7 +429,7 @@ func (m *IntIntMap) Merge(other *IntIntMap) { // String returns the map as a string. func (m *IntIntMap) String() string { b, _ := m.MarshalJSON() - return gconv.UnsafeBytesToStr(b) + return string(b) } // MarshalJSON implements the interface MarshalJSON for json.Marshal. diff --git a/container/gmap/gmap_hash_int_str_map.go b/container/gmap/gmap_hash_int_str_map.go index c5f5ac323..df5a655d8 100644 --- a/container/gmap/gmap_hash_int_str_map.go +++ b/container/gmap/gmap_hash_int_str_map.go @@ -429,7 +429,7 @@ func (m *IntStrMap) Merge(other *IntStrMap) { // String returns the map as a string. func (m *IntStrMap) String() string { b, _ := m.MarshalJSON() - return gconv.UnsafeBytesToStr(b) + return string(b) } // MarshalJSON implements the interface MarshalJSON for json.Marshal. diff --git a/container/gmap/gmap_hash_str_any_map.go b/container/gmap/gmap_hash_str_any_map.go index 04d70f664..802cd09db 100644 --- a/container/gmap/gmap_hash_str_any_map.go +++ b/container/gmap/gmap_hash_str_any_map.go @@ -454,7 +454,7 @@ func (m *StrAnyMap) Merge(other *StrAnyMap) { // String returns the map as a string. func (m *StrAnyMap) String() string { b, _ := m.MarshalJSON() - return gconv.UnsafeBytesToStr(b) + return string(b) } // MarshalJSON implements the interface MarshalJSON for json.Marshal. diff --git a/container/gmap/gmap_hash_str_int_map.go b/container/gmap/gmap_hash_str_int_map.go index 7bc03cd34..f01fcaa8d 100644 --- a/container/gmap/gmap_hash_str_int_map.go +++ b/container/gmap/gmap_hash_str_int_map.go @@ -432,7 +432,7 @@ func (m *StrIntMap) Merge(other *StrIntMap) { // String returns the map as a string. func (m *StrIntMap) String() string { b, _ := m.MarshalJSON() - return gconv.UnsafeBytesToStr(b) + return string(b) } // MarshalJSON implements the interface MarshalJSON for json.Marshal. diff --git a/container/gmap/gmap_hash_str_str_map.go b/container/gmap/gmap_hash_str_str_map.go index ae68640c8..cfbc945b2 100644 --- a/container/gmap/gmap_hash_str_str_map.go +++ b/container/gmap/gmap_hash_str_str_map.go @@ -432,7 +432,7 @@ func (m *StrStrMap) Merge(other *StrStrMap) { // String returns the map as a string. func (m *StrStrMap) String() string { b, _ := m.MarshalJSON() - return gconv.UnsafeBytesToStr(b) + return string(b) } // MarshalJSON implements the interface MarshalJSON for json.Marshal. diff --git a/container/gmap/gmap_list_map.go b/container/gmap/gmap_list_map.go index 790998da7..805b565f1 100644 --- a/container/gmap/gmap_list_map.go +++ b/container/gmap/gmap_list_map.go @@ -513,7 +513,7 @@ func (m *ListMap) Merge(other *ListMap) { // String returns the map as a string. func (m *ListMap) String() string { b, _ := m.MarshalJSON() - return gconv.UnsafeBytesToStr(b) + return string(b) } // MarshalJSON implements the interface MarshalJSON for json.Marshal. diff --git a/container/gtype/byte.go b/container/gtype/byte.go index 3b2a8d09b..14fcafe1d 100644 --- a/container/gtype/byte.go +++ b/container/gtype/byte.go @@ -60,12 +60,12 @@ func (v *Byte) String() string { // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (v *Byte) MarshalJSON() ([]byte, error) { - return gconv.UnsafeStrToBytes(strconv.FormatUint(uint64(v.Val()), 10)), nil + return []byte(strconv.FormatUint(uint64(v.Val()), 10)), nil } // UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal. func (v *Byte) UnmarshalJSON(b []byte) error { - v.Set(gconv.Uint8(gconv.UnsafeBytesToStr(b))) + v.Set(gconv.Uint8(string(b))) return nil } diff --git a/container/gtype/bytes.go b/container/gtype/bytes.go index 9574558cb..eae89a722 100644 --- a/container/gtype/bytes.go +++ b/container/gtype/bytes.go @@ -59,7 +59,7 @@ func (v *Bytes) MarshalJSON() ([]byte, error) { val := v.Val() dst := make([]byte, base64.StdEncoding.EncodedLen(len(val))) base64.StdEncoding.Encode(dst, val) - return gconv.UnsafeStrToBytes(`"` + gconv.UnsafeBytesToStr(dst) + `"`), nil + return []byte(`"` + string(dst) + `"`), nil } // UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal. diff --git a/container/gtype/float32.go b/container/gtype/float32.go index 2eaeb8960..5c2ffea03 100644 --- a/container/gtype/float32.go +++ b/container/gtype/float32.go @@ -73,12 +73,12 @@ func (v *Float32) String() string { // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (v *Float32) MarshalJSON() ([]byte, error) { - return gconv.UnsafeStrToBytes(strconv.FormatFloat(float64(v.Val()), 'g', -1, 32)), nil + return []byte(strconv.FormatFloat(float64(v.Val()), 'g', -1, 32)), nil } // UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal. func (v *Float32) UnmarshalJSON(b []byte) error { - v.Set(gconv.Float32(gconv.UnsafeBytesToStr(b))) + v.Set(gconv.Float32(string(b))) return nil } diff --git a/container/gtype/float64.go b/container/gtype/float64.go index ecc80facc..9a7de8c32 100644 --- a/container/gtype/float64.go +++ b/container/gtype/float64.go @@ -73,12 +73,12 @@ func (v *Float64) String() string { // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (v *Float64) MarshalJSON() ([]byte, error) { - return gconv.UnsafeStrToBytes(strconv.FormatFloat(v.Val(), 'g', -1, 64)), nil + return []byte(strconv.FormatFloat(v.Val(), 'g', -1, 64)), nil } // UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal. func (v *Float64) UnmarshalJSON(b []byte) error { - v.Set(gconv.Float64(gconv.UnsafeBytesToStr(b))) + v.Set(gconv.Float64(string(b))) return nil } diff --git a/container/gtype/int.go b/container/gtype/int.go index c1b2543f0..7c9ea774a 100644 --- a/container/gtype/int.go +++ b/container/gtype/int.go @@ -60,12 +60,12 @@ func (v *Int) String() string { // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (v *Int) MarshalJSON() ([]byte, error) { - return gconv.UnsafeStrToBytes(strconv.Itoa(v.Val())), nil + return []byte(strconv.Itoa(v.Val())), nil } // UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal. func (v *Int) UnmarshalJSON(b []byte) error { - v.Set(gconv.Int(gconv.UnsafeBytesToStr(b))) + v.Set(gconv.Int(string(b))) return nil } diff --git a/container/gtype/int32.go b/container/gtype/int32.go index 63d4a5d23..07ac0acf3 100644 --- a/container/gtype/int32.go +++ b/container/gtype/int32.go @@ -60,12 +60,12 @@ func (v *Int32) String() string { // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (v *Int32) MarshalJSON() ([]byte, error) { - return gconv.UnsafeStrToBytes(strconv.Itoa(int(v.Val()))), nil + return []byte(strconv.Itoa(int(v.Val()))), nil } // UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal. func (v *Int32) UnmarshalJSON(b []byte) error { - v.Set(gconv.Int32(gconv.UnsafeBytesToStr(b))) + v.Set(gconv.Int32(string(b))) return nil } diff --git a/container/gtype/int64.go b/container/gtype/int64.go index b9c356ebd..ed2a65d06 100644 --- a/container/gtype/int64.go +++ b/container/gtype/int64.go @@ -60,12 +60,12 @@ func (v *Int64) String() string { // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (v *Int64) MarshalJSON() ([]byte, error) { - return gconv.UnsafeStrToBytes(strconv.FormatInt(v.Val(), 10)), nil + return []byte(strconv.FormatInt(v.Val(), 10)), nil } // UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal. func (v *Int64) UnmarshalJSON(b []byte) error { - v.Set(gconv.Int64(gconv.UnsafeBytesToStr(b))) + v.Set(gconv.Int64(string(b))) return nil } diff --git a/container/gtype/string.go b/container/gtype/string.go index 0e1483b6f..f0b89f4ca 100644 --- a/container/gtype/string.go +++ b/container/gtype/string.go @@ -55,12 +55,12 @@ func (v *String) String() string { // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (v *String) MarshalJSON() ([]byte, error) { - return gconv.UnsafeStrToBytes(`"` + v.Val() + `"`), nil + return []byte(`"` + v.Val() + `"`), nil } // UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal. func (v *String) UnmarshalJSON(b []byte) error { - v.Set(gconv.UnsafeBytesToStr(bytes.Trim(b, `"`))) + v.Set(string(bytes.Trim(b, `"`))) return nil } diff --git a/container/gtype/uint.go b/container/gtype/uint.go index b9203a9af..a6e35996f 100644 --- a/container/gtype/uint.go +++ b/container/gtype/uint.go @@ -60,12 +60,12 @@ func (v *Uint) String() string { // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (v *Uint) MarshalJSON() ([]byte, error) { - return gconv.UnsafeStrToBytes(strconv.FormatUint(uint64(v.Val()), 10)), nil + return []byte(strconv.FormatUint(uint64(v.Val()), 10)), nil } // UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal. func (v *Uint) UnmarshalJSON(b []byte) error { - v.Set(gconv.Uint(gconv.UnsafeBytesToStr(b))) + v.Set(gconv.Uint(string(b))) return nil } diff --git a/container/gtype/uint32.go b/container/gtype/uint32.go index 2fbdcb030..d1f4ea736 100644 --- a/container/gtype/uint32.go +++ b/container/gtype/uint32.go @@ -60,12 +60,12 @@ func (v *Uint32) String() string { // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (v *Uint32) MarshalJSON() ([]byte, error) { - return gconv.UnsafeStrToBytes(strconv.FormatUint(uint64(v.Val()), 10)), nil + return []byte(strconv.FormatUint(uint64(v.Val()), 10)), nil } // UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal. func (v *Uint32) UnmarshalJSON(b []byte) error { - v.Set(gconv.Uint32(gconv.UnsafeBytesToStr(b))) + v.Set(gconv.Uint32(string(b))) return nil } diff --git a/container/gtype/uint64.go b/container/gtype/uint64.go index 580163bb5..7791eeac3 100644 --- a/container/gtype/uint64.go +++ b/container/gtype/uint64.go @@ -60,12 +60,12 @@ func (v *Uint64) String() string { // MarshalJSON implements the interface MarshalJSON for json.Marshal. func (v *Uint64) MarshalJSON() ([]byte, error) { - return gconv.UnsafeStrToBytes(strconv.FormatUint(v.Val(), 10)), nil + return []byte(strconv.FormatUint(v.Val(), 10)), nil } // UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal. func (v *Uint64) UnmarshalJSON(b []byte) error { - v.Set(gconv.Uint64(gconv.UnsafeBytesToStr(b))) + v.Set(gconv.Uint64(string(b))) return nil } diff --git a/database/gdb/gdb_type_record.go b/database/gdb/gdb_type_record.go index eff35a1f4..14c26b9e6 100644 --- a/database/gdb/gdb_type_record.go +++ b/database/gdb/gdb_type_record.go @@ -22,13 +22,13 @@ func (r Record) Interface() interface{} { // Json converts `r` to JSON format content. func (r Record) Json() string { content, _ := gparser.VarToJson(r.Map()) - return gconv.UnsafeBytesToStr(content) + return string(content) } // Xml converts `r` to XML format content. func (r Record) Xml(rootTag ...string) string { content, _ := gparser.VarToXml(r.Map(), rootTag...) - return gconv.UnsafeBytesToStr(content) + return string(content) } // Map converts `r` to map[string]interface{}. diff --git a/database/gredis/gredis_conn.go b/database/gredis/gredis_conn.go index a56e9ddd7..347fe79be 100644 --- a/database/gredis/gredis_conn.go +++ b/database/gredis/gredis_conn.go @@ -117,7 +117,7 @@ func (c *Conn) ReceiveVarWithTimeout(timeout time.Duration) (*gvar.Var, error) { func resultToVar(result interface{}, err error) (*gvar.Var, error) { if err == nil { if result, ok := result.([]byte); ok { - return gvar.New(gconv.UnsafeBytesToStr(result)), err + return gvar.New(string(result)), err } // It treats all returned slice as string slice. if result, ok := result.([]interface{}); ok { diff --git a/encoding/gbase64/gbase64.go b/encoding/gbase64/gbase64.go index b88373677..30e104aec 100644 --- a/encoding/gbase64/gbase64.go +++ b/encoding/gbase64/gbase64.go @@ -9,7 +9,6 @@ package gbase64 import ( "encoding/base64" - "github.com/gogf/gf/util/gconv" "io/ioutil" ) @@ -27,7 +26,7 @@ func EncodeString(src string) string { // EncodeToString encodes bytes to string with BASE64 algorithm. func EncodeToString(src []byte) string { - return gconv.UnsafeBytesToStr(Encode(src)) + return string(Encode(src)) } // EncryptFile encodes file content of using BASE64 algorithms. @@ -55,7 +54,7 @@ func EncodeFileToString(path string) (string, error) { if err != nil { return "", err } - return gconv.UnsafeBytesToStr(content), nil + return string(content), nil } // MustEncodeFileToString encodes file content of to string using BASE64 algorithms. @@ -103,7 +102,7 @@ func MustDecodeString(data string) []byte { // DecodeString decodes string with BASE64 algorithm. func DecodeToString(data string) (string, error) { b, err := DecodeString(data) - return gconv.UnsafeBytesToStr(b), err + return string(b), err } // MustDecodeToString decodes string with BASE64 algorithm. diff --git a/encoding/gjson/gjson_api_encoding.go b/encoding/gjson/gjson_api_encoding.go index cea7a8a1b..559a20464 100644 --- a/encoding/gjson/gjson_api_encoding.go +++ b/encoding/gjson/gjson_api_encoding.go @@ -12,7 +12,6 @@ import ( "github.com/gogf/gf/encoding/gxml" "github.com/gogf/gf/encoding/gyaml" "github.com/gogf/gf/internal/json" - "github.com/gogf/gf/util/gconv" ) // ======================================================================== @@ -50,7 +49,7 @@ func (j *Json) MustToJson() []byte { } func (j *Json) MustToJsonString() string { - return gconv.UnsafeBytesToStr(j.MustToJson()) + return string(j.MustToJson()) } func (j *Json) MustToJsonIndent() []byte { @@ -62,7 +61,7 @@ func (j *Json) MustToJsonIndent() []byte { } func (j *Json) MustToJsonIndentString() string { - return gconv.UnsafeBytesToStr(j.MustToJsonIndent()) + return string(j.MustToJsonIndent()) } // ======================================================================== @@ -96,7 +95,7 @@ func (j *Json) MustToXml(rootTag ...string) []byte { } func (j *Json) MustToXmlString(rootTag ...string) string { - return gconv.UnsafeBytesToStr(j.MustToXml(rootTag...)) + return string(j.MustToXml(rootTag...)) } func (j *Json) MustToXmlIndent(rootTag ...string) []byte { @@ -108,7 +107,7 @@ func (j *Json) MustToXmlIndent(rootTag ...string) []byte { } func (j *Json) MustToXmlIndentString(rootTag ...string) string { - return gconv.UnsafeBytesToStr(j.MustToXmlIndent(rootTag...)) + return string(j.MustToXmlIndent(rootTag...)) } // ======================================================================== @@ -135,7 +134,7 @@ func (j *Json) MustToYaml() []byte { } func (j *Json) MustToYamlString() string { - return gconv.UnsafeBytesToStr(j.MustToYaml()) + return string(j.MustToYaml()) } // ======================================================================== @@ -162,7 +161,7 @@ func (j *Json) MustToToml() []byte { } func (j *Json) MustToTomlString() string { - return gconv.UnsafeBytesToStr(j.MustToToml()) + return string(j.MustToToml()) } // ======================================================================== @@ -192,5 +191,5 @@ func (j *Json) MustToIni() []byte { // MustToIniString . func (j *Json) MustToIniString() string { - return gconv.UnsafeBytesToStr(j.MustToIni()) + return string(j.MustToIni()) } diff --git a/net/ghttp/ghttp_request_param.go b/net/ghttp/ghttp_request_param.go index 737e2ec44..c6a044d97 100644 --- a/net/ghttp/ghttp_request_param.go +++ b/net/ghttp/ghttp_request_param.go @@ -175,7 +175,7 @@ func (r *Request) GetBody() []byte { // GetBodyString retrieves and returns request body content as string. // It can be called multiple times retrieving the same body content. func (r *Request) GetBodyString() string { - return gconv.UnsafeBytesToStr(r.GetBody()) + return string(r.GetBody()) } // GetJson parses current request content as JSON format, and returns the JSON object. @@ -375,7 +375,7 @@ func (r *Request) parseForm() { // It might be JSON/XML content. if s := gstr.Trim(name + strings.Join(values, " ")); len(s) > 0 { if s[0] == '{' && s[len(s)-1] == '}' || s[0] == '<' && s[len(s)-1] == '>' { - r.bodyContent = gconv.UnsafeStrToBytes(s) + r.bodyContent = []byte(s) params = "" break } diff --git a/net/ghttp/internal/client/client_dump.go b/net/ghttp/internal/client/client_dump.go index 9ac718a65..38774ab36 100644 --- a/net/ghttp/internal/client/client_dump.go +++ b/net/ghttp/internal/client/client_dump.go @@ -12,8 +12,6 @@ import ( "io/ioutil" "net/http" "net/http/httputil" - - "github.com/gogf/gf/util/gconv" ) // dumpTextFormat is the format of the dumped raw string @@ -31,7 +29,7 @@ func getResponseBody(res *http.Response) string { } bodyContent, _ := ioutil.ReadAll(res.Body) res.Body = utils.NewReadCloser(bodyContent, true) - return gconv.UnsafeBytesToStr(bodyContent) + return string(bodyContent) } // RawRequest returns the raw content of the request. @@ -51,7 +49,7 @@ func (r *Response) RawRequest() string { return fmt.Sprintf( dumpTextFormat, "REQUEST ", - gconv.UnsafeBytesToStr(bs), + string(bs), r.requestBody, ) } @@ -70,7 +68,7 @@ func (r *Response) RawResponse() string { return fmt.Sprintf( dumpTextFormat, "RESPONSE", - gconv.UnsafeBytesToStr(bs), + string(bs), getResponseBody(r.Response), ) } diff --git a/net/ghttp/internal/client/client_response.go b/net/ghttp/internal/client/client_response.go index 324115ebf..54699562c 100644 --- a/net/ghttp/internal/client/client_response.go +++ b/net/ghttp/internal/client/client_response.go @@ -9,8 +9,6 @@ package client import ( "io/ioutil" "net/http" - - "github.com/gogf/gf/util/gconv" ) // Response is the struct for client request response. @@ -65,7 +63,7 @@ func (r *Response) ReadAll() []byte { // ReadAllString retrieves and returns the response content as string. func (r *Response) ReadAllString() string { - return gconv.UnsafeBytesToStr(r.ReadAll()) + return string(r.ReadAll()) } // Close closes the response when it will never be used. diff --git a/net/gsmtp/gsmtp.go b/net/gsmtp/gsmtp.go index 46e5dec59..f7dc845b6 100644 --- a/net/gsmtp/gsmtp.go +++ b/net/gsmtp/gsmtp.go @@ -95,7 +95,7 @@ func (s *SMTP) SendMail(from, tos, subject, body string, contentType ...string) header := map[string]string{ "From": from, "To": strings.Join(tosArr, ";"), - "Subject": fmt.Sprintf("=?UTF-8?B?%s?=", contentEncoding.EncodeToString(gconv.UnsafeStrToBytes(subject))), + "Subject": fmt.Sprintf("=?UTF-8?B?%s?=", contentEncoding.EncodeToString([]byte(subject))), "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "base64", @@ -107,12 +107,12 @@ func (s *SMTP) SendMail(from, tos, subject, body string, contentType ...string) for k, v := range header { message += fmt.Sprintf("%s: %s\r\n", k, v) } - message += "\r\n" + contentEncoding.EncodeToString(gconv.UnsafeStrToBytes(body)) + message += "\r\n" + contentEncoding.EncodeToString([]byte(body)) return smtp.SendMail( address, smtp.PlainAuth("", s.Username, s.Password, server), from, tosArr, - gconv.UnsafeStrToBytes(message), + []byte(message), ) } diff --git a/os/gfile/gfile_contents.go b/os/gfile/gfile_contents.go index 048e15d76..29057ddaa 100644 --- a/os/gfile/gfile_contents.go +++ b/os/gfile/gfile_contents.go @@ -11,8 +11,6 @@ import ( "io" "io/ioutil" "os" - - "github.com/gogf/gf/util/gconv" ) var ( @@ -23,7 +21,7 @@ var ( // GetContents returns the file content of as string. // It returns en empty string if it fails reading. func GetContents(path string) string { - return gconv.UnsafeBytesToStr(GetBytes(path)) + return string(GetBytes(path)) } // GetBytes returns the file content of as []byte. diff --git a/os/gres/gres_func.go b/os/gres/gres_func.go index 4995fbc29..cf45d7a8c 100644 --- a/os/gres/gres_func.go +++ b/os/gres/gres_func.go @@ -13,10 +13,8 @@ import ( "fmt" "github.com/gogf/gf/encoding/gbase64" "github.com/gogf/gf/encoding/gcompress" - "github.com/gogf/gf/text/gstr" - "github.com/gogf/gf/util/gconv" - "github.com/gogf/gf/os/gfile" + "github.com/gogf/gf/text/gstr" ) const ( @@ -116,7 +114,7 @@ func UnpackContent(content string) ([]*File, error) { return nil, err } } else { - data, err = gcompress.UnGzip(gconv.UnsafeStrToBytes(content)) + data, err = gcompress.UnGzip([]byte(content)) if err != nil { return nil, err } @@ -166,7 +164,7 @@ func isHexStr(s string) bool { // hexStrToBytes converts hex string content to []byte. func hexStrToBytes(s string) []byte { - src := gconv.UnsafeStrToBytes(s) + src := []byte(s) dst := make([]byte, hex.DecodedLen(len(src))) hex.Decode(dst, src) return dst diff --git a/os/gview/gview_buildin.go b/os/gview/gview_buildin.go index da22f78fa..281e15515 100644 --- a/os/gview/gview_buildin.go +++ b/os/gview/gview_buildin.go @@ -222,7 +222,7 @@ func (view *View) buildInFuncNl2Br(str interface{}) string { // which encodes and returns `value` as JSON string. func (view *View) buildInFuncJson(value interface{}) (string, error) { b, err := json.Marshal(value) - return gconv.UnsafeBytesToStr(b), err + return string(b), err } // buildInFuncPlus implements build-in template function: plus , diff --git a/os/gview/gview_parse.go b/os/gview/gview_parse.go index c8a4811ee..0fd3a095a 100644 --- a/os/gview/gview_parse.go +++ b/os/gview/gview_parse.go @@ -10,26 +10,23 @@ import ( "bytes" "context" "fmt" + "github.com/gogf/gf/container/gmap" "github.com/gogf/gf/encoding/ghash" "github.com/gogf/gf/errors/gcode" "github.com/gogf/gf/errors/gerror" "github.com/gogf/gf/internal/intlog" + "github.com/gogf/gf/os/gfile" "github.com/gogf/gf/os/gfsnotify" + "github.com/gogf/gf/os/glog" "github.com/gogf/gf/os/gmlock" + "github.com/gogf/gf/os/gres" + "github.com/gogf/gf/os/gspath" "github.com/gogf/gf/text/gstr" - "github.com/gogf/gf/util/gconv" "github.com/gogf/gf/util/gutil" htmltpl "html/template" "strconv" "strings" texttpl "text/template" - - "github.com/gogf/gf/os/gres" - - "github.com/gogf/gf/container/gmap" - "github.com/gogf/gf/os/gfile" - "github.com/gogf/gf/os/glog" - "github.com/gogf/gf/os/gspath" ) const ( @@ -71,7 +68,7 @@ func (view *View) Parse(ctx context.Context, file string, params ...Params) (res return nil } if resource != nil { - content = gconv.UnsafeBytesToStr(resource.Content()) + content = string(resource.Content()) } else { content = gfile.GetContentsWithCache(path) } diff --git a/util/guid/guid_string.go b/util/guid/guid_string.go index 666d0ec8d..e8386aeb8 100644 --- a/util/guid/guid_string.go +++ b/util/guid/guid_string.go @@ -10,7 +10,6 @@ import ( "github.com/gogf/gf/container/gtype" "github.com/gogf/gf/encoding/ghash" "github.com/gogf/gf/net/gipv4" - "github.com/gogf/gf/util/gconv" "github.com/gogf/gf/util/grand" "os" "strconv" @@ -94,7 +93,7 @@ func S(data ...[]byte) string { } else { panic("too many data parts, it should be no more than 2 parts") } - return gconv.UnsafeBytesToStr(b) + return string(b) } // getSequence increases and returns the sequence string in 3 bytes.