GetString will try to get the value stored under name as a string will respond with an error if the value does not exist or cannot be converted to a string
(name string)
| 187 | // GetString will try to get the value stored under name as a string |
| 188 | // will respond with an error if the value does not exist or cannot be converted to a string |
| 189 | func (section *Section) GetString(name string) (string, error) { |
| 190 | value, err := section.Get(name) |
| 191 | if err != nil { |
| 192 | return "", err |
| 193 | } |
| 194 | |
| 195 | switch value.(type) { |
| 196 | case *Primative: |
| 197 | return value.(*Primative).AsString() |
| 198 | } |
| 199 | |
| 200 | return "", errors.New("could not convert non-primative value to string") |
| 201 | } |
| 202 | |
| 203 | // GetParent will get the parent section associated with this Section or nil |
| 204 | // if it does not have one |