-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add explicit privilege prompt to improve sudo UX (#138) * Explicitly prompt for privilege escallation * Remove password prompt part of privilege message * Expand sudo detection. * Tidy up timing issues. * Consolidate messaging and avoid newline in verbose. * Cleanup ToString, sudo contains, cover more exec methods. * Lint does not catch all of fmt. * Remove unnecessary password prompt from networking cleanup. * Remove color reset and cat /dev/null to clear route text. * trying a different approach to requesting for admin privs (#144)
- Loading branch information
Showing
4 changed files
with
99 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package util | ||
|
||
import ( | ||
"strings" | ||
) | ||
|
||
// IndexOfString is a general utility function that can find the index of a value | ||
// present in a string slice. The second value is true if the item is found. | ||
func IndexOfString(slice []string, search string) (int, bool) { | ||
for index, elem := range slice { | ||
if elem == search { | ||
return index, true | ||
} | ||
} | ||
|
||
return 0, false | ||
} | ||
|
||
// IndexOfSubstring is a variation on IndexOfString which checks to see if a | ||
// given slice value matches our search string, or if that search string is | ||
// a substring of the element. The second value is true if the item is found. | ||
func IndexOfSubstring(slice []string, search string) (int, bool) { | ||
for index, elem := range slice { | ||
if strings.Contains(elem, search) { | ||
return index, true | ||
} | ||
} | ||
|
||
return 0, false | ||
} |