Created
April 5, 2020 00:12
-
-
Save MAAARKIN/c193bb8ca230d22947d6435dedb60a49 to your computer and use it in GitHub Desktop.
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
package service | |
import ( | |
"github.com/maaarkin/errors-handling/pkg/domains/todo" | |
"github.com/pkg/errors" | |
) | |
//TodoService representa o servico que poderá ser exporto para a camada de consumo (rest, grpc, rabbitmq, etc...) | |
type TodoService interface { | |
Save(title string) (*todo.Todo, error) | |
} | |
type todoService struct { | |
} | |
//NewTodoService função que tem como responsabilidade inicializar a interface do TodoService | |
func NewTodoService() TodoService { | |
return todoService{} | |
} | |
func (t todoService) Save(value string) (*todo.Todo, error) { | |
if value == "" { | |
return nil, errors.WithStack(todo.TodoTitleError{}) | |
} | |
if value == "teste" { | |
return nil, todo.TodoTitleError{} | |
} | |
out := todo.Todo{ | |
Title: value, | |
} | |
return &out, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment