package HyTools import ( "bytes" "encoding/json" "fmt" ) type StringBuilder struct { buf bytes.Buffer } func NewStringBuilder() *StringBuilder { return &StringBuilder{buf: bytes.Buffer{}} } func (this *StringBuilder) Append(obj any) *StringBuilder { this.buf.WriteString(fmt.Sprintf("%v", obj)) return this } func (this *StringBuilder) ToString() string { return this.buf.String() } // 字符串转int32 func JsonStr(v any) string { bys, _ := json.Marshal(v) return string(bys) }