Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type BookForm struct {
- Title string `json:"title"`
- Author string `json:"author"`
- PublishedDate string `json:"published_date"`
- ImageUrl string `json:"image_url"`
- Description string `json:"description"`
- }
- func (f *BookForm) ToModel() (*Book, error) {
- pubDate, err := time.Parse("2006-01-02", f.PublishedDate)
- if err != nil {
- return nil, err
- }
- return &Book{
- Title: f.Title,
- Author: f.Author,
- PublishedDate: pubDate,
- ImageUrl: f.ImageUrl,
- Description: f.Description,
- }, nil
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement