Documentation ¶
Index ¶
- Variables
- func ADD_LEADING_ZERO(myNum int) string
- func AM_I_ROOT() bool
- func CLIPBOARD_COPY(instring string)
- func COPY_FILE(source_file string, dest_file_name string)
- func CURR_DIR() string
- func DELETE_ITEM[T any](slice []T, s int) []T
- func DELETE_from_LIST[T any](slice []T, s int) []T
- func DETERMINE_Current_OS_and_PLATFORM()
- func DOES_FILE_CONTAIN(filename string, lookfor string) bool
- func DOES_FILE_EXIST(FULL_path_2_file string, ALL_PARAMS ...string) bool
- func DOEXIT(EXTRA_ARGS ...string)
- func DO_EXIT(EXTRA_ARGS ...string)
- func DownloadFile(filepath string, url string) error
- func FILE_EXISTS(path string) bool
- func FLOAT_to_STRING(input float64, ALL_PARAMS ...int) string
- func FLOAT_to_STRING32(input float32, ALL_PARAMS ...int) string
- func GEN_UNIQUE_ID(GENFROM ...interface{}) (string, string)
- func GET_BINARY_BUILT_FOR() (string, string)
- func GET_CURRENT_TIME(ALL_PARAMS ...string) (string, time.Time)
- func GET_EXTRA_ARG(key interface{}, EXTRA_ARGS ...interface{}) interface{}
- func GET_FILE_MD5(filePath string) (string, error)
- func GET_FILE_SIZE(bytes int64) (float64, float64)
- func GET_INPUT() string
- func GET_LAST_CHARs(s string, c int) string
- func GET_MD5(input string) string
- func GET_MONTH_NUM(month_name string) (string, int)
- func GET_PUBLIC_IP() string
- func GET_USER_INPUT(ALL_PARAMS ...interface{}) string
- func GenRandomRange(min int, max int) (int, string)
- func GenSerial(serial_length int) string
- func HAVE_DIR(input string) bool
- func HAVE_LINK(input string) bool
- func HasOnlyNumbers(s string) bool
- func INT64_to_STRING(input int64) string
- func INT_to_STRING(input int) string
- func IS_BOOL(param interface{}) bool
- func IS_DIR(input string) bool
- func IS_FILE_LINK(filename string) bool
- func IS_FLOAT(param interface{}) bool
- func IS_INT(param interface{}) bool
- func IS_LINK(input string) bool
- func IS_ODD_Num(inum int) bool
- func IS_STRING(param interface{}) bool
- func JUST_ALPHA_STRING(input string) string
- func LINK_ORIGIN(filename string) string
- func LOAD_Struct_from_FILE(FULL_path_2_file string, v interface{}, bequiet bool) error
- func MAKE_Sure_Running_As_ROOT()
- func MASTER_INIT(PROGNAME string, VERSION string, ALL_PARAMS ...string)
- func MOST_RECENT_DATE(first time.Time, second time.Time) bool
- func NEW_UUID() string
- func NO_EXTRA_Spaces(input string) string
- func OPEN_FILE(path_to_file string) *os.File
- func PAD_STRING(input string, TOTAL_FINAL_LEN int, ALL_PARAMS ...string) string
- func PLACEHOLDER()
- func PLACE_HOLDER()
- func PRETTY_STRUCT_json(input interface{}) string
- func PROMPT(warning_TEXT string, required_input string)
- func Pager(tmax int)
- func PressAny(ALL_PARAMS ...interface{})
- func REMOVE_from_LIST[T any](slice []T, s int) []T
- func RUN_COMMAND(command_text string, ALL_PARAMS ...string) (string, []string)
- func SAVE_Struct_2_DISK(dest_file string, v interface{}) error
- func SHOW_BOX(ALL_PARAMS ...string)
- func SHOW_PERCENT(ALL_PARAMS ...interface{}) string
- func SHOW_PRETTY_DATE(input_DATE time.Time, EXTRA_ARGS ...string) (string, string)
- func SHOW_PROG_VERSION(vernum string)
- func SHOW_STRUCT(ALL_PARAMS ...interface{})
- func SHUFFLE_STRING(input_STRING string) string
- func START_Spinner()
- func STOP_Spinner()
- func STRING_to_FLOAT(input string) float64
- func STRING_to_FLOAT32(input string) float32
- func STRING_to_INT(input string) int
- func STRING_to_INT64(input string) int64
- func ShowNum(innum int) string
- func ShowNum64(innum int64) string
- func ShowNum_FLOAT(innum float64) string
- func Show_Total_RUNTIME()
- func Sleep(seconds int, ALL_PARAMS ...bool)
- func TOUCH_FILE(filename string)
- func UNICODE_REMOVE_ALL_SPACES(str string) string
- func UpperFirst(inString string) string
- func VERIFICATION_PROMPT(warning_TEXT string, required_input string, ALL_PARAMS ...interface{}) bool
- func WRITE_FILE(FULL_FILENAME string, TEXT_for_FILE string, ALL_PARAMS ...string) bool
- type FILE_INFO_OBJ
- type IP
Constants ¶
This section is empty.
Variables ¶
var BOX_INDENT_SPACES = " "
This is a nice way of showing a message in a box Just pass each line you want in the box as a seperate parameter
╭――――――――――――――――――╮ │ │ │ │ │ │ ╰――――――――――――――――――╯
var CHECK_VERSION = false
var CURRENT_ARCH = ""
var CURRENT_OS = ""
var DEBUG_MODE = false
var GLOBAL_CURR_DATE = "" // Current Actual Date in the Timezone we specified
var Marshal = func(v interface{}) (io.Reader, error) { b, err := json.MarshalIndent(v, "", "\t") if err != nil { return nil, err } return bytes.NewReader(b), nil }
var NULL_FLOAT = -69.69696969
var NULL_INT = -69696969
Generic null ints and floats to use .. when using just 0 isnt sufficient
var ON_ARM = false
var ON_LINUX = false
We need to determine what the CURRENT running platform is
var ON_MAC = false
var ON_WINDOWS = false
var PAGE_COUNT = 0
var PAGE_MAX = 5
var PROG_START_TIME string
var PROG_START_TIMEOBJ time.Time
Reverse w UNDERLINE.. Only setting up the ones that work best on Black background terminals
This shows with UNDERLINE
var SPINNER_CHAR = 4
var SPINNER_SPEED = 100
var USING_ARM = false
var Unmarshal = func(r io.Reader, v interface{}) error { return json.NewDecoder(r).Decode(v) }
Unmarshal is a function that unmarshals the data from the reader into the specified value. By default, it uses the JSON unmarshaller.
Functions ¶
func ADD_LEADING_ZERO ¶
ADD_LEADING_ZERO: This takes in a number and returns a string with a leading 0 If the number is already 10 or greater, it returns that same number as is SHOW_PRETTY_DATE is dependant on this
func CLIPBOARD_COPY ¶
func CLIPBOARD_COPY(instring string)
When called, copies a specified string to the users CLIPBOARD
func DELETE_ITEM ¶
func DELETE_from_LIST ¶
func DETERMINE_Current_OS_and_PLATFORM ¶
func DETERMINE_Current_OS_and_PLATFORM()
func DOES_FILE_CONTAIN ¶
func DOES_FILE_EXIST ¶
func DO_EXIT ¶
func DO_EXIT(EXTRA_ARGS ...string)
Easy way to quick exit a program without having to remember to import os
func DownloadFile ¶
DownloadFile will download a url to a local file. It's efficient because it will write as it downloads and not load the whole file into memory.
Courtesy of: https://golangcode.com/download-a-file-from-a-url/
func FILE_EXISTS ¶
This checks to see if a file or directory exists
func FLOAT_to_STRING ¶
Converts a float to a string.. If another number is specified, it is interpreted as decimal precision
func FLOAT_to_STRING32 ¶
func GEN_UNIQUE_ID ¶
gens a 'unique' id from the values provided. Use this to insert into the ID field for mongo
func GET_BINARY_BUILT_FOR ¶
This gets the platform we are running on (mac, linux, windows)
func GET_EXTRA_ARG ¶
func GET_EXTRA_ARG(key interface{}, EXTRA_ARGS ...interface{}) interface{}
FOr Dynamic Parameter support... DONT FORGET THE ... thre dots!!! Examples:
for function call: WRITE_EMBED("ca.pem.gz", "verbose", "quiet", 55, "www.podshop.com")
Then write the function like this: func WRITE_EMBED(name string, EXTRA_ARGS ...interface{}) string { var verbose = GET_EXTRA_ARG("verbose", EXTRA_ARGS...).(bool) // specify verbose will set to TRUE... case verbase was passed as a parameter var bequiet = GET_EXTRA_ARG(1, EXTRA_ARGS...).(string) // parameter at index 1 is quiet.. So bequiet is set to string "quiet"
var antcount = GET_EXTRA_ARG(2, EXTRA_ARGS...).(int) // parameter at index 2 is the number 55... so antcount is set to specify 2 to get the INT value 55 that was specified var mydomain = GET_EXTRA_ARG(3, EXTRA_ARGS...).(string) // and.. specify 3 to get the param at index 3 (which is www.podshop.com) C.Println(" RESULT Verbose is: ", verbose) C.Println(" antcount is: ", antcount) C.Println(" mydomain is: ", mydomain) }
func GET_FILE_MD5 ¶
Easy way to get teh MD5 of a file
func GET_FILE_SIZE ¶
Returns file size in MEGS and BYTES
func GET_LAST_CHARs ¶
func GET_MONTH_NUM ¶
Gets a numeric month from a text indicator
func GET_USER_INPUT ¶
func GET_USER_INPUT(ALL_PARAMS ...interface{}) string
func GenRandomRange ¶
Returns a randomly generated number within a given range (returns a STRING AND an int)
func GenSerial ¶
This generates a serial.. usually used discern between multiple execution runs like in jenkins
func HasOnlyNumbers ¶
Returns true if the string contains ONLY numbers
func INT64_to_STRING ¶
func INT_to_STRING ¶
func IS_FILE_LINK ¶
Determines if a file is a sym link or not
func IS_INT ¶
func IS_INT(param interface{}) bool
= = = = = = = = = = = = Better versions of the IS_xxx functions = = = = = =
func IS_ODD_Num ¶
func JUST_ALPHA_STRING ¶
This takes in a string and removes all non alphanumeric chars from it.. and extra spaces
func LOAD_Struct_from_FILE ¶
Load loads the file at path into v. Use os.IsNotExist() to see if the returned error is due to the file being missing.
func MAKE_Sure_Running_As_ROOT ¶
func MAKE_Sure_Running_As_ROOT()
This makes sure we're running as run.. program exists otherwise
func MASTER_INIT ¶
func MOST_RECENT_DATE ¶
If first is more recent than second, we return true
func NO_EXTRA_Spaces ¶
This removes all extra spaces in a string
func PAD_STRING ¶
This padds a string that is passed and makes it a total LENGH of TOTAL_FINAL_LEN Pass a character as a string param and it will pad with THAT char instead of space
func PLACEHOLDER ¶
func PLACEHOLDER()
func PLACE_HOLDER ¶
func PLACE_HOLDER()
a simple placeholder.. if you arent using anything in GOGO Gadgets main (at the moment) this will prevent you getting a "imported but not used" error
func PRETTY_STRUCT_json ¶
func PRETTY_STRUCT_json(input interface{}) string
func Pager ¶
func Pager(tmax int)
This is a basic Paging routine that prompts you to PressAny key after x number of items have been shown
func REMOVE_from_LIST ¶
func RUN_COMMAND ¶
NOTE here is teh way to use cmd.Exec WITH environment variables: cmd := exec.Command("go", "build", "-ldflags=-s -w -X main.VERSION_NUM=" + VERSION_to_USE, "-buildmode=exe", "-o", FULL_DEST_FILE ) cmd.Env = os.Environ() cmd.Env = append(cmd.Env, "GOOS=" + BIN_TYPE) cmd.Env = append(cmd.Env, "GOARCH=" + ARCH) output, err := cmd.CombinedOutput() if err != nil { R.Println(" Error in RUN COMMAND: ", err) } C.Println(string(output))
Much better ver of RUN_COMMAND Specify -verbose -rundir or -showoutput, -hideerror
func SAVE_Struct_2_DISK ¶
EXTRA_ARGS ...interface{}) {
var have_alt, alt_val = GET_EXTRA_ARG(0, EXTRA_ARGS...) var verbose, _ = GET_EXTRA_ARG("verbose", EXTRA_ARGS...)
func SHOW_PERCENT ¶
func SHOW_PERCENT(ALL_PARAMS ...interface{}) string
This takes in a number (float) and shows it as pretty PERCENT string // Specify another INT to define PRECISION
func SHOW_PRETTY_DATE ¶
SHOW_PRETTY_DATE Takes in a time.Time DATE_OBJ and returns a PRETTY formatted based on what you specify
For FORMAT specifiy: basic, simple, full, nano, british, justtime, justdate, timestamp You can also modify format by adding: _noday (ie, basic_noweek) - Prevents the weekday info from showing _nozone - prevents the timezone info from showing _reset_time - For situations where you want to omit the HH:MM cause you dont need it...resets time to 00:00
func SHOW_PROG_VERSION ¶
func SHOW_PROG_VERSION(vernum string)
func SHOW_STRUCT ¶
func SHOW_STRUCT(ALL_PARAMS ...interface{})
Super Useful to show structures... ANY Structure .. in JSON Format
func SHUFFLE_STRING ¶
This takes IN a string and returns a shuffle of the characters contained in it
func START_Spinner ¶
func START_Spinner()
Creates a cool "im busy right now" status spinner so you know the program is running
func STOP_Spinner ¶
func STOP_Spinner()
func STRING_to_FLOAT ¶
func STRING_to_FLOAT32 ¶
func STRING_to_INT ¶
func STRING_to_INT64 ¶
func ShowNum ¶
This utilizes the HUMANIZE library and shows a HUMAN readable number of the passed variable
func ShowNum_FLOAT ¶
Shows a pretty Number based on passed FLOAT
func Show_Total_RUNTIME ¶
func Show_Total_RUNTIME()
Shows the amount of time a program ran (and start and end time)
func TOUCH_FILE ¶
func TOUCH_FILE(filename string)
func UNICODE_REMOVE_ALL_SPACES ¶
This removes all spaces from a string via unicode
func UpperFirst ¶
Make sthe first character of a string UPPER CASE