Created
August 21, 2017 18:15
-
-
Save batmany13/817b1e42975910c0f505cead5858c190 to your computer and use it in GitHub Desktop.
Value and Scan for Synq Video object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (v Video) Value() (driver.Value, error) { | |
json, err := json.Marshal(v) | |
return json, err | |
} | |
func (v *Video) Scan(src interface{}) error { | |
source, ok := src.([]byte) | |
if !ok { | |
return errors.New("Type assertion .([]byte) failed.") | |
} | |
err := json.Unmarshal(source, &v) | |
if err != nil { | |
return err | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment