MCPcopy
hub / github.com/bwmarrin/snowflake / Base58

Method Base58

snowflake.go:250–268  ·  view source on GitHub ↗

Base58 returns a base58 string of the snowflake ID

()

Source from the content-addressed store, hash-verified

248
249// Base58 returns a base58 string of the snowflake ID
250func (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
271func ParseBase58(b []byte) (ID, error) {

Callers 4

TestPrintAllFunction · 0.80
TestBase58Function · 0.80
BenchmarkParseBase58Function · 0.80
BenchmarkBase58Function · 0.80

Calls

no outgoing calls

Tested by 4

TestPrintAllFunction · 0.64
TestBase58Function · 0.64
BenchmarkParseBase58Function · 0.64
BenchmarkBase58Function · 0.64