SHARE
TWEET

Untitled

a guest Aug 23rd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. type BookForm struct {
  2.     Title         string `json:"title"`
  3.     Author        string `json:"author"`
  4.     PublishedDate string `json:"published_date"`
  5.     ImageUrl      string `json:"image_url"`
  6.     Description   string `json:"description"`
  7. }
  8.  
  9. func (f *BookForm) ToModel() (*Book, error) {
  10.     pubDate, err := time.Parse("2006-01-02", f.PublishedDate)
  11.     if err != nil {
  12.         return nil, err
  13.     }
  14.  
  15.     return &Book{
  16.         Title:         f.Title,
  17.         Author:        f.Author,
  18.         PublishedDate: pubDate,
  19.         ImageUrl:      f.ImageUrl,
  20.         Description:   f.Description,
  21.     }, nil
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top