1
0
Fork 0
justguestbook/guestbook/reply.go

24 lines
409 B
Go
Raw Normal View History

2022-10-19 03:25:43 +04:00
package guestbook
import (
"errors"
"time"
)
type Reply struct {
2023-02-05 16:28:55 +04:00
ID int64 `json:"-"`
Created time.Time `json:"created,omitempty"`
Message string `json:"message"`
2022-10-19 03:25:43 +04:00
}
func NewReply(entryID int64, message string) (*Reply, error) {
if message == "" {
return nil, errors.New("empty reply field")
}
return &Reply{
ID: entryID,
2023-02-05 16:28:55 +04:00
Created: time.Now().UTC(),
2022-10-19 03:25:43 +04:00
Message: message}, nil
}