Created
April 15, 2019 19:38
-
-
Save napolux/30f287ee211c96141779197b22e9df5b to your computer and use it in GitHub Desktop.
service.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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