From 66ea462704b7902e0f3602e596171b47ae119137 Mon Sep 17 00:00:00 2001 From: what Date: Tue, 26 Nov 2024 15:20:08 +0800 Subject: [PATCH] [fix] GetInstance Memory confusion --- base62.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/base62.go b/base62.go index c1d6465..0c661e9 100644 --- a/base62.go +++ b/base62.go @@ -12,15 +12,10 @@ type Base62 struct { charactersMap map[byte]int // base62 编码规则 } -var _base62 *Base62 - -func init() { - _base62 = &Base62{} - _base62.SetCharacters([]byte("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")) -} - func GetInstance() *Base62 { - return _base62 + b62 := &Base62{} + b62.SetCharacters([]byte("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")) + return b62 } func (base62 *Base62) SetCharacters(characters []byte) (*Base62, error) {