blob: f11a29db1e7cfea49ed3dd104698f61190cbc4d8 [file] [log] [blame]
Jamie Hannaford6abf9282014-09-24 10:54:13 +02001package gophercloud
2
3// MaybeString takes a string that might be a zero-value, and either returns a
4// pointer to its address or a nil value (i.e. empty pointer). This is useful
5// for converting zero values in options structs when the end-user hasn't
6// defined values. Those zero values need to be nil in order for the JSON
7// serialization to ignore them.
8func MaybeString(original string) *string {
9 if original != "" {
10 return &original
11 }
12 return nil
13}