MCPcopy
hub / github.com/segmentio/ksuid / Parse

Function Parse

ksuid.go:177–192  ·  view source on GitHub ↗

Parse decodes a string-encoded representation of a KSUID object

(s string)

Source from the content-addressed store, hash-verified

175
176// Parse decodes a string-encoded representation of a KSUID object
177func Parse(s string) (KSUID, error) {
178 if len(s) != stringEncodedLength {
179 return Nil, errStrSize
180 }
181
182 src := [stringEncodedLength]byte{}
183 dst := [byteLength]byte{}
184
185 copy(src[:], s[:])
186
187 if err := fastDecodeBase62(dst[:], src[:]); err != nil {
188 return Nil, errStrValue
189 }
190
191 return FromBytes(dst[:])
192}
193
194func timeToCorrectedUTCTimestamp(t time.Time) uint32 {
195 return uint32(t.Unix() - epochStamp)

Callers 10

mainFunction · 0.92
TestParseFunction · 0.85
TestIssue25Function · 0.85
TestEncodeAndDecodeFunction · 0.85
TestSqlValuerFunction · 0.85
TestAppendFunction · 0.85
BenchmarkParseFunction · 0.85
testCompressedSetStringFunction · 0.85
UnmarshalTextMethod · 0.85

Calls 2

fastDecodeBase62Function · 0.85
FromBytesFunction · 0.85

Tested by 8

TestParseFunction · 0.68
TestIssue25Function · 0.68
TestEncodeAndDecodeFunction · 0.68
TestSqlValuerFunction · 0.68
TestAppendFunction · 0.68
BenchmarkParseFunction · 0.68
testCompressedSetStringFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…