first commit
This commit is contained in:
30
pkg/common/HyTools/StringBuilder.go
Normal file
30
pkg/common/HyTools/StringBuilder.go
Normal file
@ -0,0 +1,30 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user