(original, other string)
| 171 | } |
| 172 | |
| 173 | func replace1(original, other string) (string, error) { |
| 174 | components := split(original) |
| 175 | var candidates []int |
| 176 | for idx, val := range components { |
| 177 | if val == "**" { |
| 178 | candidates = append(candidates, idx) |
| 179 | } |
| 180 | } |
| 181 | if len(candidates) != 1 { |
| 182 | return "", fmt.Errorf("expand only supports one expansion glob, pattern %s has %d", original, len(candidates)) |
| 183 | } |
| 184 | components[candidates[0]] = other |
| 185 | return strings.Join(components, "/"), nil |
| 186 | } |