Permalink
Browse files

Added GetString to Data

  • Loading branch information...
1 parent 4953852 commit 4392a6db475167abf58a517ffa72e1a290f22868 T. Jameson Little committed Apr 2, 2013
Showing with 12 additions and 0 deletions.
  1. +12 −0 core.go
View
12 core.go
@@ -15,6 +15,7 @@ var errors = map[int]string{
type Data interface {
Get(string) (interface{}, bool)
+ GetString(string) string
Set(string, interface{})
}
@@ -27,6 +28,17 @@ func (d *data) Get(key string) (interface{}, bool) {
return i, ok
}
+func (d *data) GetString(key string) string {
+ i, ok := d.raw[key]
+ if !ok {
+ return ""
+ }
+ if s, ok := i.(string); ok {
+ return s
+ }
+ return ""
+}
+
func (d *data) Set(key string, val interface{}) {
d.raw[key] = val
}

0 comments on commit 4392a6d

Please sign in to comment.