MCPcopy Create free account
hub / github.com/brettlangdon/forge / GetString

Method GetString

section.go:189–201  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
189func (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

Callers

nothing calls this directly

Calls 2

GetMethod · 0.95
AsStringMethod · 0.80

Tested by

no test coverage detected