Base58 returns a base58 string of the snowflake ID
()
| 248 | |
| 249 | // Base58 returns a base58 string of the snowflake ID |
| 250 | func (f ID) Base58() string { |
| 251 | |
| 252 | if f < 58 { |
| 253 | return string(encodeBase58Map[f]) |
| 254 | } |
| 255 | |
| 256 | b := make([]byte, 0, 11) |
| 257 | for f >= 58 { |
| 258 | b = append(b, encodeBase58Map[f%58]) |
| 259 | f /= 58 |
| 260 | } |
| 261 | b = append(b, encodeBase58Map[f]) |
| 262 | |
| 263 | for x, y := 0, len(b)-1; x < y; x, y = x+1, y-1 { |
| 264 | b[x], b[y] = b[y], b[x] |
| 265 | } |
| 266 | |
| 267 | return string(b) |
| 268 | } |
| 269 | |
| 270 | // ParseBase58 parses a base58 []byte into a snowflake ID |
| 271 | func ParseBase58(b []byte) (ID, error) { |
no outgoing calls