SetEnabled toggles the Enabled field on the named endpoint. Returns ErrNotFound if no such endpoint exists.
(file *File, name string, enabled bool)
| 152 | // SetEnabled toggles the Enabled field on the named endpoint. Returns |
| 153 | // ErrNotFound if no such endpoint exists. |
| 154 | func SetEnabled(file *File, name string, enabled bool) error { |
| 155 | if file == nil { |
| 156 | return errors.New("providers: nil file") |
| 157 | } |
| 158 | ep, ok := file.Endpoints[name] |
| 159 | if !ok { |
| 160 | return fmt.Errorf("provider %q not found: %w", name, ErrNotFound) |
| 161 | } |
| 162 | v := enabled |
| 163 | ep.Enabled = &v |
| 164 | file.Endpoints[name] = ep |
| 165 | return nil |
| 166 | } |
| 167 | |
| 168 | // ErrAlreadyExists is returned by Add and Rename when the destination key |
| 169 | // is already taken. Use errors.Is(err, ErrAlreadyExists) to detect it. |
no outgoing calls