1
0
justguestbook/internal/guestbook/entry.go

30 lines
717 B
Go
Raw Normal View History

2022-10-19 03:25:43 +04:00
package guestbook
import (
"errors"
"time"
)
type Entry struct {
ID int64 `json:"entry_id"`
Created string `json:"created"`
Name string `json:"name"`
Website string `json:"website,omitempty"`
Message string `json:"message"`
HideWebsite bool `json:"hide_website,omitempty"`
Reply *Reply `json:"reply,omitempty"`
}
func NewEntry(name, message, website string, hideWebsite bool) (*Entry, error) {
2022-10-19 03:25:43 +04:00
if name == "" || message == "" {
return nil, errors.New("name and message field are required")
}
return &Entry{
Created: time.Now().UTC().Format(DateFormat),
Name: name,
Website: website,
HideWebsite: hideWebsite,
Message: message}, nil
}