file_system.go 466 B

123456789101112131415161718192021222324252627
  1. package microsite
  2. import (
  3. "database/sql/driver"
  4. "encoding/json"
  5. "errors"
  6. )
  7. type FileSystem struct {
  8. FileName string
  9. Url string
  10. }
  11. func (this FileSystem) Value() (driver.Value, error) {
  12. return json.Marshal(this)
  13. }
  14. func (this *FileSystem) Scan(value interface{}) error {
  15. switch v := value.(type) {
  16. case string:
  17. return json.Unmarshal([]byte(v), this)
  18. case []byte:
  19. return json.Unmarshal(v, this)
  20. default:
  21. return errors.New("not supported")
  22. }
  23. }