DebugSet sets the debug variable
(which string, value string)
| 61 | |
| 62 | // DebugSet sets the debug variable |
| 63 | func DebugSet(which string, value string) { |
| 64 | // Convert the value as appropriate |
| 65 | boolValue := false |
| 66 | lcValue := strings.ToLower(value) |
| 67 | if lcValue == "t" || lcValue == "true" || lcValue == "on" { |
| 68 | boolValue = true |
| 69 | } else if lcValue == "f" || lcValue == "false" || lcValue == "off" { |
| 70 | boolValue = false |
| 71 | } else { |
| 72 | i, err := strconv.Atoi(value) |
| 73 | if err == nil { |
| 74 | if i != 0 { |
| 75 | boolValue = true |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | // Find the string |
| 81 | for i := range text { |
| 82 | if text[i] == which { |
| 83 | *(vars[i]) = boolValue |
| 84 | logInfo(context.Background(), "%s is now %t", which, boolValue) |
| 85 | return |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | // Failure |
| 90 | logError(context.Background(), "notelib debug setting %s not found", which) |
| 91 | } |
| 92 | |
| 93 | // Get the value of a boolean environment variable |
| 94 | func debugEnv(which string) (isAvail bool, value bool) { |