func (s *sampleServer) GetUsers(ctx context.Context, req *samplepb.UserSearchRequest) (*samplepb.UsersResponse, error) { users := []*User{} query := db.Debug() if req.Name != "" { query = query.Where("name LIKE ?", fmt.Sprintf("%%%s%%", req.Name)) } if req.BirthdayFrom != "" { from, _ := time.Parse(dateLayout, req.BirthdayFrom) query = query.Where("? <= birthday", from) } if req.BirthdayTo != "" { to, _ := time.Parse(dateLayout, req.BirthdayTo) query = query.Where("birthday <= ?", to) }