| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package main | 5 package main |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "regexp" | 8 "regexp" |
| 9 "strings" | 9 "strings" |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // v[m[2]:m[3]] is the paramter key (first capture group) | 33 // v[m[2]:m[3]] is the paramter key (first capture group) |
| 34 parts = append(parts, v[sidx:m[0]]) | 34 parts = append(parts, v[sidx:m[0]]) |
| 35 sidx = m[1] | 35 sidx = m[1] |
| 36 | 36 |
| 37 key := v[m[2]:m[3]] | 37 key := v[m[2]:m[3]] |
| 38 if val, ok := subs[key]; ok { | 38 if val, ok := subs[key]; ok { |
| 39 parts = append(parts, val) | 39 parts = append(parts, val) |
| 40 } else { | 40 } else { |
| 41 // panic to immediately stop matching. This will be caug
ht at the top of | 41 // panic to immediately stop matching. This will be caug
ht at the top of |
| 42 // this function. | 42 // this function. |
| 43 » » » return errors.Reason("undefined parameter %(key)q").D("k
ey", key).Err() | 43 » » » return errors.Reason("undefined parameter %q", key).Err(
) |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Finish the string and return. | 47 // Finish the string and return. |
| 48 parts = append(parts, v[sidx:]) | 48 parts = append(parts, v[sidx:]) |
| 49 *vp = strings.Join(parts, "") | 49 *vp = strings.Join(parts, "") |
| 50 return nil | 50 return nil |
| 51 } | 51 } |
| OLD | NEW |