Go实现泛型转字符串FormatString及性能测试

时间:2025-02-26 07:53:51
package gotest

import (
     "encoding/json"
     "fmt"
     "reflect"
     "strconv"
     "testing"
)

func FormatString(iface interface{}) string {
     switch val := iface.(type) {
     case [] byte:
         return string(val)
    }
     v := reflect. ValueOf(iface)
     switch v. Kind() {
     case :
         return ""