From 59d71744b6d09a5278759c8aa0eefbb6f8505279 Mon Sep 17 00:00:00 2001 From: "Sah, Nandeshwar" Date: Sun, 12 Jul 2020 14:28:27 -0600 Subject: [PATCH] Minor change removed timestamp field for generating sort and set field --- gofp/gofp.go | 2 +- internal/employee/fp.go | 42 +++++++++++++++++++++-------------------- internal/employer/fp.go | 26 +++++++++++++------------ internal/gfp/fp.go | 26 +++++++++++++------------ 4 files changed, 51 insertions(+), 45 deletions(-) diff --git a/gofp/gofp.go b/gofp/gofp.go index 32b8e86..65cab84 100644 --- a/gofp/gofp.go +++ b/gofp/gofp.go @@ -1120,7 +1120,7 @@ func findStructNamesAndFieldsGivenInGoGenerate() map[string][]string { dataType := strings.TrimSpace(words[1]) switch dataType { - case "int", "int64", "int32", "int16", "int8", "uint", "uint64", "uint32", "uint16", "uint8", "float64", "float32", "string", "time.Time": + case "int", "int64", "int32", "int16", "int8", "uint", "uint64", "uint32", "uint16", "uint8", "float64", "float32", "string": structFields = append(structFields, field+" "+dataType) } } diff --git a/internal/employee/fp.go b/internal/employee/fp.go index 116b42a..379466a 100644 --- a/internal/employee/fp.go +++ b/internal/employee/fp.go @@ -1035,6 +1035,7 @@ func TakePtr(n int, list []*Employee) []*Employee { } return newList } + func MapTeacher(f func(Teacher) Teacher, list []Teacher) []Teacher { if f == nil { return []Teacher{} @@ -2068,6 +2069,7 @@ func TakeTeacherPtr(n int, list []*Teacher) []*Teacher { return newList } + // MapEmployeeTeacher takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapEmployeeTeacher(f func(Employee) Teacher, list []Employee) []Teacher { @@ -2081,7 +2083,7 @@ func MapEmployeeTeacher(f func(Employee) Teacher, list []Employee) []Teacher { return newList } -// MapEmployeeTeacher takes two inputs - +// MapEmployeeTeacherErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapEmployeeTeacherErr(f func(Employee) (Teacher, error), list []Employee) ([]Teacher, error) { if f == nil { @@ -2098,7 +2100,7 @@ func MapEmployeeTeacherErr(f func(Employee) (Teacher, error), list []Employee) ( return newList, nil } -// MapEmployeeTeacher takes two inputs - +// MapEmployeeTeacherPtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapEmployeeTeacherPtr(f func(*Employee) *Teacher, list []*Employee) []*Teacher { if f == nil { @@ -2415,7 +2417,7 @@ func MapEmployeeInt(f func(Employee) int, list []Employee) []int { return newList } -// MapEmployeeInt takes two inputs - +// MapEmployeeIntErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapEmployeeIntErr(f func(Employee) (int, error), list []Employee) ([]int, error) { if f == nil { @@ -2432,7 +2434,7 @@ func MapEmployeeIntErr(f func(Employee) (int, error), list []Employee) ([]int, e return newList, nil } -// MapEmployeeInt takes two inputs - +// MapEmployeeIntPtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapEmployeeIntPtr(f func(*Employee) *int, list []*Employee) []*int { if f == nil { @@ -2749,7 +2751,7 @@ func MapEmployeeStr(f func(Employee) string, list []Employee) []string { return newList } -// MapEmployeeStr takes two inputs - +// MapEmployeeStrErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapEmployeeStrErr(f func(Employee) (string, error), list []Employee) ([]string, error) { if f == nil { @@ -2766,7 +2768,7 @@ func MapEmployeeStrErr(f func(Employee) (string, error), list []Employee) ([]str return newList, nil } -// MapEmployeeStr takes two inputs - +// MapEmployeeStrPtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapEmployeeStrPtr(f func(*Employee) *string, list []*Employee) []*string { if f == nil { @@ -3083,7 +3085,7 @@ func MapTeacherEmployee(f func(Teacher) Employee, list []Teacher) []Employee { return newList } -// MapTeacherEmployee takes two inputs - +// MapTeacherEmployeeErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapTeacherEmployeeErr(f func(Teacher) (Employee, error), list []Teacher) ([]Employee, error) { if f == nil { @@ -3100,7 +3102,7 @@ func MapTeacherEmployeeErr(f func(Teacher) (Employee, error), list []Teacher) ([ return newList, nil } -// MapTeacherEmployee takes two inputs - +// MapTeacherEmployeePtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapTeacherEmployeePtr(f func(*Teacher) *Employee, list []*Teacher) []*Employee { if f == nil { @@ -3417,7 +3419,7 @@ func MapTeacherInt(f func(Teacher) int, list []Teacher) []int { return newList } -// MapTeacherInt takes two inputs - +// MapTeacherIntErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapTeacherIntErr(f func(Teacher) (int, error), list []Teacher) ([]int, error) { if f == nil { @@ -3434,7 +3436,7 @@ func MapTeacherIntErr(f func(Teacher) (int, error), list []Teacher) ([]int, erro return newList, nil } -// MapTeacherInt takes two inputs - +// MapTeacherIntPtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapTeacherIntPtr(f func(*Teacher) *int, list []*Teacher) []*int { if f == nil { @@ -3751,7 +3753,7 @@ func MapTeacherStr(f func(Teacher) string, list []Teacher) []string { return newList } -// MapTeacherStr takes two inputs - +// MapTeacherStrErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapTeacherStrErr(f func(Teacher) (string, error), list []Teacher) ([]string, error) { if f == nil { @@ -3768,7 +3770,7 @@ func MapTeacherStrErr(f func(Teacher) (string, error), list []Teacher) ([]string return newList, nil } -// MapTeacherStr takes two inputs - +// MapTeacherStrPtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapTeacherStrPtr(f func(*Teacher) *string, list []*Teacher) []*string { if f == nil { @@ -4085,7 +4087,7 @@ func MapIntEmployee(f func(int) Employee, list []int) []Employee { return newList } -// MapIntEmployee takes two inputs - +// MapIntEmployeeErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapIntEmployeeErr(f func(int) (Employee, error), list []int) ([]Employee, error) { if f == nil { @@ -4102,7 +4104,7 @@ func MapIntEmployeeErr(f func(int) (Employee, error), list []int) ([]Employee, e return newList, nil } -// MapIntEmployee takes two inputs - +// MapIntEmployeePtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapIntEmployeePtr(f func(*int) *Employee, list []*int) []*Employee { if f == nil { @@ -4419,7 +4421,7 @@ func MapIntTeacher(f func(int) Teacher, list []int) []Teacher { return newList } -// MapIntTeacher takes two inputs - +// MapIntTeacherErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapIntTeacherErr(f func(int) (Teacher, error), list []int) ([]Teacher, error) { if f == nil { @@ -4436,7 +4438,7 @@ func MapIntTeacherErr(f func(int) (Teacher, error), list []int) ([]Teacher, erro return newList, nil } -// MapIntTeacher takes two inputs - +// MapIntTeacherPtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapIntTeacherPtr(f func(*int) *Teacher, list []*int) []*Teacher { if f == nil { @@ -4753,7 +4755,7 @@ func MapStrEmployee(f func(string) Employee, list []string) []Employee { return newList } -// MapStrEmployee takes two inputs - +// MapStrEmployeeErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapStrEmployeeErr(f func(string) (Employee, error), list []string) ([]Employee, error) { if f == nil { @@ -4770,7 +4772,7 @@ func MapStrEmployeeErr(f func(string) (Employee, error), list []string) ([]Emplo return newList, nil } -// MapStrEmployee takes two inputs - +// MapStrEmployeePtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapStrEmployeePtr(f func(*string) *Employee, list []*string) []*Employee { if f == nil { @@ -5087,7 +5089,7 @@ func MapStrTeacher(f func(string) Teacher, list []string) []Teacher { return newList } -// MapStrTeacher takes two inputs - +// MapStrTeacherErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapStrTeacherErr(f func(string) (Teacher, error), list []string) ([]Teacher, error) { if f == nil { @@ -5104,7 +5106,7 @@ func MapStrTeacherErr(f func(string) (Teacher, error), list []string) ([]Teacher return newList, nil } -// MapStrTeacher takes two inputs - +// MapStrTeacherPtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapStrTeacherPtr(f func(*string) *Teacher, list []*string) []*Teacher { if f == nil { diff --git a/internal/employer/fp.go b/internal/employer/fp.go index 1e16527..b7b1f6c 100644 --- a/internal/employer/fp.go +++ b/internal/employer/fp.go @@ -1036,6 +1036,7 @@ func TakePtr(n int, list []*Employer) []*Employer { } return newList } + func MapEmployee(f func(employee.Employee) employee.Employee, list []employee.Employee) []employee.Employee { if f == nil { return []employee.Employee{} @@ -2069,6 +2070,7 @@ func TakeEmployeePtr(n int, list []*employee.Employee) []*employee.Employee { return newList } + // MapEmployerEmployee takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapEmployerEmployee(f func(Employer) employee.Employee, list []Employer) []employee.Employee { @@ -2082,7 +2084,7 @@ func MapEmployerEmployee(f func(Employer) employee.Employee, list []Employer) [] return newList } -// MapEmployerEmployee takes two inputs - +// MapEmployerEmployeeErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapEmployerEmployeeErr(f func(Employer) (employee.Employee, error), list []Employer) ([]employee.Employee, error) { if f == nil { @@ -2099,7 +2101,7 @@ func MapEmployerEmployeeErr(f func(Employer) (employee.Employee, error), list [] return newList, nil } -// MapEmployerEmployee takes two inputs - +// MapEmployerEmployeePtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapEmployerEmployeePtr(f func(*Employer) *employee.Employee, list []*Employer) []*employee.Employee { if f == nil { @@ -2416,7 +2418,7 @@ func MapEmployerInt(f func(Employer) int, list []Employer) []int { return newList } -// MapEmployerInt takes two inputs - +// MapEmployerIntErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapEmployerIntErr(f func(Employer) (int, error), list []Employer) ([]int, error) { if f == nil { @@ -2433,7 +2435,7 @@ func MapEmployerIntErr(f func(Employer) (int, error), list []Employer) ([]int, e return newList, nil } -// MapEmployerInt takes two inputs - +// MapEmployerIntPtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapEmployerIntPtr(f func(*Employer) *int, list []*Employer) []*int { if f == nil { @@ -2750,7 +2752,7 @@ func MapEmployeeEmployer(f func(employee.Employee) Employer, list []employee.Emp return newList } -// MapEmployeeEmployer takes two inputs - +// MapEmployeeEmployerErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapEmployeeEmployerErr(f func(employee.Employee) (Employer, error), list []employee.Employee) ([]Employer, error) { if f == nil { @@ -2767,7 +2769,7 @@ func MapEmployeeEmployerErr(f func(employee.Employee) (Employer, error), list [] return newList, nil } -// MapEmployeeEmployer takes two inputs - +// MapEmployeeEmployerPtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapEmployeeEmployerPtr(f func(*employee.Employee) *Employer, list []*employee.Employee) []*Employer { if f == nil { @@ -3084,7 +3086,7 @@ func MapEmployeeInt(f func(employee.Employee) int, list []employee.Employee) []i return newList } -// MapEmployeeInt takes two inputs - +// MapEmployeeIntErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapEmployeeIntErr(f func(employee.Employee) (int, error), list []employee.Employee) ([]int, error) { if f == nil { @@ -3101,7 +3103,7 @@ func MapEmployeeIntErr(f func(employee.Employee) (int, error), list []employee.E return newList, nil } -// MapEmployeeInt takes two inputs - +// MapEmployeeIntPtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapEmployeeIntPtr(f func(*employee.Employee) *int, list []*employee.Employee) []*int { if f == nil { @@ -3418,7 +3420,7 @@ func MapIntEmployer(f func(int) Employer, list []int) []Employer { return newList } -// MapIntEmployer takes two inputs - +// MapIntEmployerErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapIntEmployerErr(f func(int) (Employer, error), list []int) ([]Employer, error) { if f == nil { @@ -3435,7 +3437,7 @@ func MapIntEmployerErr(f func(int) (Employer, error), list []int) ([]Employer, e return newList, nil } -// MapIntEmployer takes two inputs - +// MapIntEmployerPtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapIntEmployerPtr(f func(*int) *Employer, list []*int) []*Employer { if f == nil { @@ -3752,7 +3754,7 @@ func MapIntEmployee(f func(int) employee.Employee, list []int) []employee.Employ return newList } -// MapIntEmployee takes two inputs - +// MapIntEmployeeErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapIntEmployeeErr(f func(int) (employee.Employee, error), list []int) ([]employee.Employee, error) { if f == nil { @@ -3769,7 +3771,7 @@ func MapIntEmployeeErr(f func(int) (employee.Employee, error), list []int) ([]em return newList, nil } -// MapIntEmployee takes two inputs - +// MapIntEmployeePtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapIntEmployeePtr(f func(*int) *employee.Employee, list []*int) []*employee.Employee { if f == nil { diff --git a/internal/gfp/fp.go b/internal/gfp/fp.go index d20782f..b8f55c9 100644 --- a/internal/gfp/fp.go +++ b/internal/gfp/fp.go @@ -1036,6 +1036,7 @@ func TakeEmployerPtr(n int, list []*employer.Employer) []*employer.Employer { } return newList } + func MapEmployee(f func(employee.Employee) employee.Employee, list []employee.Employee) []employee.Employee { if f == nil { return []employee.Employee{} @@ -2069,6 +2070,7 @@ func TakeEmployeePtr(n int, list []*employee.Employee) []*employee.Employee { return newList } + // MapEmployerEmployee takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapEmployerEmployee(f func(employer.Employer) employee.Employee, list []employer.Employer) []employee.Employee { @@ -2082,7 +2084,7 @@ func MapEmployerEmployee(f func(employer.Employer) employee.Employee, list []emp return newList } -// MapEmployerEmployee takes two inputs - +// MapEmployerEmployeeErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapEmployerEmployeeErr(f func(employer.Employer) (employee.Employee, error), list []employer.Employer) ([]employee.Employee, error) { if f == nil { @@ -2099,7 +2101,7 @@ func MapEmployerEmployeeErr(f func(employer.Employer) (employee.Employee, error) return newList, nil } -// MapEmployerEmployee takes two inputs - +// MapEmployerEmployeePtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapEmployerEmployeePtr(f func(*employer.Employer) *employee.Employee, list []*employer.Employer) []*employee.Employee { if f == nil { @@ -2416,7 +2418,7 @@ func MapEmployerInt(f func(employer.Employer) int, list []employer.Employer) []i return newList } -// MapEmployerInt takes two inputs - +// MapEmployerIntErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapEmployerIntErr(f func(employer.Employer) (int, error), list []employer.Employer) ([]int, error) { if f == nil { @@ -2433,7 +2435,7 @@ func MapEmployerIntErr(f func(employer.Employer) (int, error), list []employer.E return newList, nil } -// MapEmployerInt takes two inputs - +// MapEmployerIntPtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapEmployerIntPtr(f func(*employer.Employer) *int, list []*employer.Employer) []*int { if f == nil { @@ -2750,7 +2752,7 @@ func MapEmployeeEmployer(f func(employee.Employee) employer.Employer, list []emp return newList } -// MapEmployeeEmployer takes two inputs - +// MapEmployeeEmployerErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapEmployeeEmployerErr(f func(employee.Employee) (employer.Employer, error), list []employee.Employee) ([]employer.Employer, error) { if f == nil { @@ -2767,7 +2769,7 @@ func MapEmployeeEmployerErr(f func(employee.Employee) (employer.Employer, error) return newList, nil } -// MapEmployeeEmployer takes two inputs - +// MapEmployeeEmployerPtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapEmployeeEmployerPtr(f func(*employee.Employee) *employer.Employer, list []*employee.Employee) []*employer.Employer { if f == nil { @@ -3084,7 +3086,7 @@ func MapEmployeeInt(f func(employee.Employee) int, list []employee.Employee) []i return newList } -// MapEmployeeInt takes two inputs - +// MapEmployeeIntErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapEmployeeIntErr(f func(employee.Employee) (int, error), list []employee.Employee) ([]int, error) { if f == nil { @@ -3101,7 +3103,7 @@ func MapEmployeeIntErr(f func(employee.Employee) (int, error), list []employee.E return newList, nil } -// MapEmployeeInt takes two inputs - +// MapEmployeeIntPtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapEmployeeIntPtr(f func(*employee.Employee) *int, list []*employee.Employee) []*int { if f == nil { @@ -3418,7 +3420,7 @@ func MapIntEmployer(f func(int) employer.Employer, list []int) []employer.Employ return newList } -// MapIntEmployer takes two inputs - +// MapIntEmployerErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapIntEmployerErr(f func(int) (employer.Employer, error), list []int) ([]employer.Employer, error) { if f == nil { @@ -3435,7 +3437,7 @@ func MapIntEmployerErr(f func(int) (employer.Employer, error), list []int) ([]em return newList, nil } -// MapIntEmployer takes two inputs - +// MapIntEmployerPtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapIntEmployerPtr(f func(*int) *employer.Employer, list []*int) []*employer.Employer { if f == nil { @@ -3752,7 +3754,7 @@ func MapIntEmployee(f func(int) employee.Employee, list []int) []employee.Employ return newList } -// MapIntEmployee takes two inputs - +// MapIntEmployeeErr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list and error func MapIntEmployeeErr(f func(int) (employee.Employee, error), list []int) ([]employee.Employee, error) { if f == nil { @@ -3769,7 +3771,7 @@ func MapIntEmployeeErr(f func(int) (employee.Employee, error), list []int) ([]em return newList, nil } -// MapIntEmployee takes two inputs - +// MapIntEmployeePtr takes two inputs - // 1. Function 2. List. Then It returns a new list after applying the function on each item of the list func MapIntEmployeePtr(f func(*int) *employee.Employee, list []*int) []*employee.Employee { if f == nil {