(key string, params []string)
| 43 | } |
| 44 | |
| 45 | func (b *Block) UpdateDirective(key string, params []string) { |
| 46 | if key == "" || len(params) == 0 { |
| 47 | return |
| 48 | } |
| 49 | directives := b.GetDirectives() |
| 50 | index := -1 |
| 51 | for i, dir := range directives { |
| 52 | if dir.GetName() == key { |
| 53 | if IsRepeatKey(key) { |
| 54 | oldParams := dir.GetParameters() |
| 55 | if !(len(oldParams) > 0 && oldParams[0] == params[0]) { |
| 56 | continue |
| 57 | } |
| 58 | } |
| 59 | index = i |
| 60 | break |
| 61 | } |
| 62 | } |
| 63 | newDirective := &Directive{ |
| 64 | Name: key, |
| 65 | Parameters: params, |
| 66 | } |
| 67 | if index > -1 { |
| 68 | directives[index] = newDirective |
| 69 | } else { |
| 70 | directives = append(directives, newDirective) |
| 71 | } |
| 72 | b.Directives = directives |
| 73 | } |
| 74 | |
| 75 | func (b *Block) RemoveDirective(key string, params []string) { |
| 76 | directives := b.GetDirectives() |
nothing calls this directly
no test coverage detected