29 lines
474 B
Go
29 lines
474 B
Go
package postgres
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
)
|
|
|
|
type UserDto struct {
|
|
}
|
|
|
|
type InMemoryUserRepository struct {
|
|
users map[int]*UserDto
|
|
}
|
|
|
|
func NewInMemoryUserRepository() *InMemoryUserRepository {
|
|
return &InMemoryUserRepository{
|
|
users: make(map[int]*UserDto),
|
|
}
|
|
}
|
|
|
|
func (ur *InMemoryUserRepository) Get(ctx context.Context, id int) (*UserDto, error) {
|
|
user := ur.users[id]
|
|
if user == nil {
|
|
return nil, errors.New("user is not in database")
|
|
}
|
|
|
|
return user, nil
|
|
}
|