GetString returns the underlying string value from the parameter.
(name string)
| 237 | |
| 238 | // GetString returns the underlying string value from the parameter. |
| 239 | func (pars Params) GetString(name string) (string, error) { |
| 240 | par, err := pars.findParam(name) |
| 241 | if err != nil { |
| 242 | return "", err |
| 243 | } |
| 244 | if _, ok := par.Value.(string); !ok { |
| 245 | return "", fmt.Errorf("unable to type cast %q parameter to string value", name) |
| 246 | } |
| 247 | return par.Value.(string), nil |
| 248 | } |
| 249 | |
| 250 | // MustGetString returns the string parameter or panics |
| 251 | // if an error occurs while trying to get the parameter. |