DieIfError kills the program if err is not nil. func DieIfError(err error, message string) { if err != nil { // log.Fatalf("%s.\nFailed with error: %v", message, err) log.WithError(err).Fatalf("%s", message) } } ListContains checks if a list of strings contains a string
(list []string, contains string)
| 66 | |
| 67 | // ListContains checks if a list of strings contains a string |
| 68 | func ListContains(list []string, contains string) bool { |
| 69 | for i := 0; i < len(list); i++ { |
| 70 | if list[i] == contains { |
| 71 | return true |
| 72 | } |
| 73 | } |
| 74 | return false |
| 75 | } |
| 76 | |
| 77 | // CheckBetter checks if better is greater than check. If it is, it returns better, otherwise it returns check. It also returns a BoolAnd of checkbetter and if better > check. |
| 78 | func CheckBetter(check int, better int, checkbetter bool) (int, bool) { |