Skip to content

Instantly share code, notes, and snippets.

@markphelps
Created August 20, 2017 21:23
Show Gist options
  • Save markphelps/b761c99918095b62e9baa6297f4ade50 to your computer and use it in GitHub Desktop.
Save markphelps/b761c99918095b62e9baa6297f4ade50 to your computer and use it in GitHub Desktop.
package optional
type String struct {
string string
present bool
}
func EmptyString() String {
return String{}
}
func OfString(s string) String {
return String{string: s, present: true}
}
func (o *String) Set(s string) {
o.string = s
o.present = true
}
func (o *String) Get() string {
return o.string
}
func (o *String) Present() bool {
return o.present
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment