MCPcopy
hub / github.com/perkeep/perkeep / parse

Function parse

pkg/blob/ref.go:219–242  ·  view source on GitHub ↗
(s string, allowAll bool)

Source from the content-addressed store, hash-verified

217}
218
219func parse(s string, allowAll bool) (ref Ref, ok bool) {
220 i := strings.Index(s, "-")
221 if i < 0 {
222 return
223 }
224 name := s[:i] // e.g. "sha1", "sha224"
225 hex := s[i+1:]
226 meta, ok := metaFromString[name]
227 if !ok {
228 if allowAll || testRefType[name] {
229 return parseUnknown(name, hex)
230 }
231 return
232 }
233 if len(hex) != meta.size*2 {
234 ok = false
235 return
236 }
237 dt, ok := meta.ctors(hex)
238 if !ok {
239 return
240 }
241 return Ref{dt}, true
242}
243
244var testRefType = map[string]bool{
245 "fakeref": true,

Callers 2

ParseKnownFunction · 0.70
ParseFunction · 0.70

Calls 2

parseUnknownFunction · 0.85
IndexMethod · 0.80

Tested by

no test coverage detected