README ¶
Go-tools
The functions found here are tools that I find useful for everyday development.
Installation
Simply run go get github.com/CrestFallenTurtle/Go-tools
to add it to your project
Contents
The following table contains all tools available in this project.
Function | Description | Note |
---|---|---|
Contains |
Checks if the the supplied string contains a substring | Returns a map[string]bool |
EraseDelimiter |
Erases any delimiter from your string | |
GenerateRandomBool |
Generates and returns true or false | |
GenerateRandomIntBetween |
Generates a random int in an interval | |
GenerateRandomInt |
Generates a random int between 1 and 128 | |
GrabCWD |
Returns the current working directory | Exits on error |
GrabExecutableName |
Returns the executables name | |
GrabExecutablePath |
Returns the path where the executable is housed | |
GrabHomeDir |
Returns the current users home directory | Exits on error |
GrabUsername |
Returns the current users username | Exits on error |
ReverseString |
Reverses a string | |
SplitString |
Splits a string and returns a rune array | |
StartsWith |
Checks if a string starts with a substring | |
EndsWith |
Checks if a string ends with a substring | |
StringToBoolean |
Converts a string to a boolean | Requires that the string is "true" or "false" |
StringToInt |
Converts a string to a int | Returns -1 when it fails to convert |
IntToString |
Converts a int to a string |
Examples
Check out the files under test/
to see how each function can be utilized
Documentation ¶
Index ¶
- func Contains(target string, selection []string) map[string]bool
- func EndsWith(target string, selection []string) map[string]bool
- func EraseDelimiter(line string, delimiters []string, count int) string
- func GenerateRandomBool() bool
- func GenerateRandomInt() int
- func GenerateRandomIntBetween(min int, max int) int
- func Generate_random_n_string(size int) string
- func Generate_random_string() string
- func GrabCWD() string
- func GrabExecutableName() string
- func GrabExecutablePath() string
- func GrabHomeDir() string
- func GrabUsername() string
- func IntToString(value int) string
- func ReverseString(target *string)
- func SplitString(target string) []string
- func StartsWith(target string, selection []string) map[string]bool
- func StringToBoolean(value string) bool
- func StringToInt(value string) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
Wrapper for the strings.Contains function, but takes in a array contaning strings to look for and returns a map in the format of { "<key>":"<true/false>" }
func EndsWith ¶
Wrapper for the strings.HasSuffix function, but takes in a array contaning strings to look for and returns a map in the format of { "<key>":"<true/false>" }
func EraseDelimiter ¶
Erases all occurences of the delimiter in the string
func GenerateRandomIntBetween ¶
Generates a random number between min and max
func Generate_random_n_string ¶
Generates a random string based on the length of the input
func Generate_random_string ¶
func Generate_random_string() string
Generates a random string between the lengthes of 1 and 128
func GrabExecutablePath ¶
func GrabExecutablePath() string
Returns the path to the executable file including the executable file name
func ReverseString ¶
func ReverseString(target *string)
Takes the string to work in as a pointer, and makes it go from abc to cba
func SplitString ¶
Splits a string into a string array and returns it
func StartsWith ¶
Wrapper for the strings.HasPrefix function, but takes in a array contaning strings to look for and returns a map in the format of { "<key>":"<true/false>" }
func StringToBoolean ¶
Converts the provided string to into a boolean
func StringToInt ¶
Tries to convert the provided string to an int, and returns either the converted value or -1 if it failed
Types ¶
This section is empty.
Source Files ¶
- contains.go
- ends_with.go
- erase_delimiter.go
- generate_random_bool.go
- generate_random_int.go
- generate_random_string.go
- grab_current_working_dir.go
- grab_executable_name.go
- grab_executable_path.go
- grab_home_dir.go
- grab_username.go
- int_to_string.go
- reverse_string.go
- split_string.go
- starts_with.go
- string_to_bool.go
- string_to_int.go