Hi all! I need an gopher advice. What is more idiomatic and do you see any problems with my solutions?
Problem: I have a repository(persistence layer) for TodoLists. TodoLists usually belongs to a user. My system also have super-user/admin interface which can access all TodoLists. I can imagine something like this. But I think it is maybe not good, because mixing not user-scoped API and user scoped API type TodoListID int type TodoList struct {} type TodoListRepository interface { Add(t *TodoList) error Update(t *TodoList) error Remove(id TodoListID) error All() ([]*TodoList, error) Find(id TodoListID) (* TodoList, error) // user scoped API TodoListsForUserID(id UserID) ([]*TodoList, error) AddTodo(t *Todo, u UserID) RemoveTodo(t *Todo, u UserID) } So I got this idea: Separate the interfaces type TodoListRepository interface { Add(t *TodoList) error Update(t *TodoList) error Remove(id TodoListID) error All() ([]*TodoList, error) Find(id TodoListID) (* TodoList, error) } type UserTodoListsRepository interface { All() ([]*TodoList, error) AddTodo(t *Todo) RemoveTodo(t *Todo) } So I would define a struct wich implements UserTodoListsRepository interface and one struct for not user-scoped TodoListsRepository. Do I miss something? Bad or good design? Thanks all in advance! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.