Skip to content

Instantly share code, notes, and snippets.

@napolux
Created April 15, 2019 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save napolux/30f287ee211c96141779197b22e9df5b to your computer and use it in GitHub Desktop.
Save napolux/30f287ee211c96141779197b22e9df5b to your computer and use it in GitHub Desktop.
service.go
type dateService struct{}
// NewService makes a new Service.
func NewService() Service {
return dateService{}
}
// Status only tell us that our service is ok!
func (dateService) Status(ctx context.Context) (string, error) {
return "ok", nil
}
// Get will return today's date
func (dateService) Get(ctx context.Context) (string, error) {
now := time.Now()
return now.Format("02/01/2006"), nil
}
// Validate will check if the date today's date
func (dateService) Validate(ctx context.Context, date string) (bool, error) {
_, err := time.Parse("02/01/2006", date)
if err != nil {
return false, err
}
return true, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment