[fix] Encode Not using characters

This commit is contained in:
what 2024-11-26 15:15:53 +08:00
parent 79c590957c
commit 8161aae4ef

View File

@ -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 ""
}