getKey returns the key which is held in s by two brackets. It also returns the next selector.
(s string)
| 81 | // getKey returns the key which is held in s by two brackets. |
| 82 | // It also returns the next selector. |
| 83 | func getKey(s string) (string, string) { |
| 84 | selSegs := strings.SplitN(s, PathSeparator, 2) |
| 85 | thisSel := selSegs[0] |
| 86 | nextSel := "" |
| 87 | |
| 88 | if len(selSegs) > 1 { |
| 89 | nextSel = selSegs[1] |
| 90 | } |
| 91 | |
| 92 | mapMatches := mapAccessRegex.FindStringSubmatch(s) |
| 93 | if len(mapMatches) > 0 { |
| 94 | if _, err := strconv.Atoi(mapMatches[2]); err != nil { |
| 95 | thisSel = mapMatches[1] |
| 96 | nextSel = "[" + mapMatches[2] + "]" + mapMatches[3] |
| 97 | |
| 98 | if thisSel == "" { |
| 99 | thisSel = mapMatches[2] |
| 100 | nextSel = mapMatches[3] |
| 101 | } |
| 102 | |
| 103 | if nextSel == "" { |
| 104 | selSegs = []string{"", ""} |
| 105 | } else if nextSel[0] == '.' { |
| 106 | nextSel = nextSel[1:] |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | return thisSel, nextSel |
| 112 | } |
| 113 | |
| 114 | // access accesses the object using the selector and performs the |
| 115 | // appropriate action. |
no outgoing calls
no test coverage detected
searching dependent graphs…