🎨 增加 Go 后端
This commit is contained in:
1 parent
04c82ab25d
commit
61275be2bf
165 files changed
+7043
-3599
No files matched your search
@@ -0,0 +1,24 @@
|
||||
package convert
|
||||
|
||||
const (
|
||||
base62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
)
|
||||
|
||||
func IntToBase62(n int) string {
|
||||
if n == 0 {
|
||||
return string(base62[0])
|
||||
}
|
||||
|
||||
var result []byte
|
||||
for n > 0 {
|
||||
result = append(result, base62[n%62])
|
||||
n /= 62
|
||||
}
|
||||
|
||||
// 反转字符串
|
||||
for i, j := 0, len(result)-1; i < j; i, j = i+1, j-1 {
|
||||
result[i], result[j] = result[j], result[i]
|
||||
}
|
||||
|
||||
return string(result)
|
||||
}
|
||||
Reference in new issue
Block a user