[fix] Encode Not using characters
This commit is contained in:
parent
79c590957c
commit
8161aae4ef
10
base62.go
10
base62.go
@ -12,15 +12,15 @@ type Base62 struct {
|
||||
charactersMap map[byte]int // base62 编码规则
|
||||
}
|
||||
|
||||
var base62 *Base62
|
||||
var _base62 *Base62
|
||||
|
||||
func init() {
|
||||
base62 = &Base62{}
|
||||
base62.SetCharacters([]byte("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
|
||||
_base62 = &Base62{}
|
||||
_base62.SetCharacters([]byte("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))
|
||||
}
|
||||
|
||||
func GetInstance() *Base62 {
|
||||
return base62
|
||||
return _base62
|
||||
}
|
||||
|
||||
func (base62 *Base62) SetCharacters(characters []byte) (*Base62, error) {
|
||||
@ -42,7 +42,7 @@ func (base62 *Base62) SetCharacters(characters []byte) (*Base62, error) {
|
||||
}
|
||||
|
||||
// Encode function receives a byte slice and encodes it to a string using the alphabet provided
|
||||
func (e *Base62) Encode(source []byte) string {
|
||||
func (base62 *Base62) Encode(source []byte) string {
|
||||
if len(source) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user