MCPcopy Create free account
hub / github.com/alecthomas/devtodo2 / indexFromString

Function indexFromString

todo.go:317–328  ·  view source on GitHub ↗

Convert "1.2.3" to int[]{0, 1, 2} ready for indexing into TaskNodes

(index string)

Source from the content-addressed store, hash-verified

315
316// Convert "1.2.3" to int[]{0, 1, 2} ready for indexing into TaskNodes
317func indexFromString(index string) Index {
318 tokens := strings.Split(index, ".")
319 numericIndex := make(Index, len(tokens))
320 for i, token := range tokens {
321 value, err := strconv.Atoi(token)
322 if err != nil || value < 1 {
323 return nil
324 }
325 numericIndex[i] = value - 1
326 }
327 return numericIndex
328}
329
330func (t *taskListImpl) ID() int {
331 return -1

Callers 2

FindMethod · 0.85
TestIndexFromStringFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestIndexFromStringFunction · 0.68