Skip to content

Commit

Permalink
refactor(常量): 不对外暴露内部常量值
Browse files Browse the repository at this point in the history
  • Loading branch information
storezhang committed Mar 6, 2023
1 parent f096907 commit 6b3a566
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
8 changes: 3 additions & 5 deletions const.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package gox

const (
// StringEmpty 空字符串
StringEmpty = ""
StringSpace = " "
stringEmpty = ""
stringSpace = " "

// Float64Size 64位长度
Float64Size = 64
float64Size = 64
)
4 changes: 2 additions & 2 deletions itoa.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ func Atoid(num string) int64 {
// Atoi 增强版进制转换,支持任意进制,最大76进制
func Atoi(num string, base int) int64 {
final := 0.0
length := len(strings.Split(num, StringEmpty)) - 1
for _, value := range strings.Split(num, StringEmpty) {
length := len(strings.Split(num, stringEmpty)) - 1
for _, value := range strings.Split(num, stringEmpty) {
tmp := float64(findKey(value))
if -1 != tmp {
final = final + tmp*math.Pow(float64(base), float64(length))
Expand Down
4 changes: 2 additions & 2 deletions size.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Size int64
// ParseSize 解析字节大小
func ParseSize(from string) (size Size, err error) {
// 逐步解析各个容量
for _, volume := range strings.Split(from, StringSpace) {
for _, volume := range strings.Split(from, stringSpace) {
var unit, num string
length := len(volume)
check := volume[length-2]
Expand All @@ -37,7 +37,7 @@ func ParseSize(from string) (size Size, err error) {

// 计算数字大小
var capacity float64
if capacity, err = strconv.ParseFloat(num, Float64Size); nil != err {
if capacity, err = strconv.ParseFloat(num, float64Size); nil != err {
return
}

Expand Down
2 changes: 1 addition & 1 deletion string_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type stringBuilder struct {
buffer *bytes.Buffer
}

// 创建连写字符串
// StringBuilder 创建连写字符串
func StringBuilder(items ...any) (sb *stringBuilder) {
sb = new(stringBuilder)
sb.buffer = new(bytes.Buffer)
Expand Down

0 comments on commit 6b3a566

Please sign in to comment.