First working version. Can add Projects and Tasks

This commit is contained in:
Anis Ahmad
2020-05-25 23:18:48 +06:00
parent 267995124b
commit 6f9580d98a
12 changed files with 610 additions and 0 deletions

27
util/array.go Normal file
View File

@@ -0,0 +1,27 @@
package util
import "reflect"
// InArray checks is val exists in a Slice
func InArray(val interface{}, array interface{}) bool {
return AtArrayPosition(val, array) != -1
}
// AtArrayPosition find the int position of val in a Slice
func AtArrayPosition(val interface{}, array interface{}) (index int) {
index = -1
switch reflect.TypeOf(array).Kind() {
case reflect.Slice:
s := reflect.ValueOf(array)
for i := 0; i < s.Len(); i++ {
if reflect.DeepEqual(val, s.Index(i).Interface()) == true {
index = i
return
}
}
}
return
}