Files
servicebase/pkg/common/HyTools/StringBuilder.go
2025-11-18 17:48:20 +08:00

31 lines
512 B
Go

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 interface{}) *StringBuilder {
this.buf.WriteString(fmt.Sprintf("%v", obj))
return this
}
func (this *StringBuilder) ToString() string {
return this.buf.String()
}
// 字符串转int32
func JsonStr(v interface{}) string {
bys, _ := json.Marshal(v)
return string(bys)
}