CUSTOM_GO_MODULE

package module
v0.0.0-...-8ef9365 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 27 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

╭――――――――――――――――――╮ │ │ │ │ │ │ ╰――――――――――――――――――╯

View Source
var CHECK_VERSION = false
View Source
var CURRENT_ARCH = ""
View Source
var CURRENT_OS = ""
View Source
var DEBUG_MODE = false
View Source
var GLOBAL_CURR_DATE = "" // Current Actual Date in the Timezone we specified
View Source
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
}
View Source
var NULL_FLOAT = -69.69696969
View Source
var NULL_INT = -69696969

Generic null ints and floats to use .. when using just 0 isnt sufficient

View Source
var ON_ARM = false
View Source
var ON_LINUX = false

We need to determine what the CURRENT running platform is

View Source
var ON_MAC = false
View Source
var ON_WINDOWS = false
View Source
var PAGE_COUNT = 0
View Source
var PAGE_MAX = 5
View Source
var PROG_START_TIME string
View Source
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

View Source
var SPINNER_CHAR = 4
View Source
var SPINNER_SPEED = 100
View Source
var USING_ARM = false
View Source
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

func ADD_LEADING_ZERO(myNum int) string
   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 AM_I_ROOT

func AM_I_ROOT() bool

func CLIPBOARD_COPY

func CLIPBOARD_COPY(instring string)

When called, copies a specified string to the users CLIPBOARD

func COPY_FILE

func COPY_FILE(source_file string, dest_file_name string)

func CURR_DIR

func CURR_DIR() string

func DELETE_ITEM

func DELETE_ITEM[T any](slice []T, s int) []T

func DELETE_from_LIST

func DELETE_from_LIST[T any](slice []T, s int) []T

func DETERMINE_Current_OS_and_PLATFORM

func DETERMINE_Current_OS_and_PLATFORM()

func DOES_FILE_CONTAIN

func DOES_FILE_CONTAIN(filename string, lookfor string) bool

func DOES_FILE_EXIST

func DOES_FILE_EXIST(FULL_path_2_file string, ALL_PARAMS ...string) bool

func DOEXIT

func DOEXIT(EXTRA_ARGS ...string)

alias

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

func DownloadFile(filepath string, url string) error

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

func FILE_EXISTS(path string) bool

This checks to see if a file or directory exists

func FLOAT_to_STRING

func FLOAT_to_STRING(input float64, ALL_PARAMS ...int) string

Converts a float to a string.. If another number is specified, it is interpreted as decimal precision

func FLOAT_to_STRING32

func FLOAT_to_STRING32(input float32, ALL_PARAMS ...int) string

func GEN_UNIQUE_ID

func GEN_UNIQUE_ID(GENFROM ...interface{}) (string, string)

gens a 'unique' id from the values provided. Use this to insert into the ID field for mongo

func GET_BINARY_BUILT_FOR

func GET_BINARY_BUILT_FOR() (string, string)

This gets the platform we are running on (mac, linux, windows)

func GET_CURRENT_TIME

func GET_CURRENT_TIME(ALL_PARAMS ...string) (string, time.Time)

func GET_EXTRA_ARG

func GET_EXTRA_ARG(key interface{}, EXTRA_ARGS ...interface{}) interface{}

FOr Dynamic Parameter support... DONT FORGET THE ... thre dots!!! Examples:

  1. for function call: WRITE_EMBED("ca.pem.gz", "verbose", "quiet", 55, "www.podshop.com")

  2. 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

func GET_FILE_MD5(filePath string) (string, error)

Easy way to get teh MD5 of a file

func GET_FILE_SIZE

func GET_FILE_SIZE(bytes int64) (float64, float64)

Returns file size in MEGS and BYTES

func GET_INPUT

func GET_INPUT() string

func GET_LAST_CHARs

func GET_LAST_CHARs(s string, c int) string

func GET_MD5

func GET_MD5(input string) string

GEts the MD5 of a string

func GET_MONTH_NUM

func GET_MONTH_NUM(month_name string) (string, int)

Gets a numeric month from a text indicator

func GET_PUBLIC_IP

func GET_PUBLIC_IP() string

Easy way to get your public IP

func GET_USER_INPUT

func GET_USER_INPUT(ALL_PARAMS ...interface{}) string

func GenRandomRange

func GenRandomRange(min int, max int) (int, string)

Returns a randomly generated number within a given range (returns a STRING AND an int)

func GenSerial

func GenSerial(serial_length int) string

This generates a serial.. usually used discern between multiple execution runs like in jenkins

func HAVE_DIR

func HAVE_DIR(input string) bool
func HAVE_LINK(input string) bool

func HasOnlyNumbers

func HasOnlyNumbers(s string) bool

Returns true if the string contains ONLY numbers

func INT64_to_STRING

func INT64_to_STRING(input int64) string

func INT_to_STRING

func INT_to_STRING(input int) string

func IS_BOOL

func IS_BOOL(param interface{}) bool

func IS_DIR

func IS_DIR(input string) bool
func IS_FILE_LINK(filename string) bool

Determines if a file is a sym link or not

func IS_FLOAT

func IS_FLOAT(param interface{}) bool

func IS_INT

func IS_INT(param interface{}) bool

= = = = = = = = = = = = Better versions of the IS_xxx functions = = = = = =

func IS_LINK(input string) bool

func IS_ODD_Num

func IS_ODD_Num(inum int) bool

func IS_STRING

func IS_STRING(param interface{}) bool

func JUST_ALPHA_STRING

func JUST_ALPHA_STRING(input string) string

This takes in a string and removes all non alphanumeric chars from it.. and extra spaces

func LINK_ORIGIN(filename string) string

Also gets the LINK_ORIGIN

func LOAD_Struct_from_FILE

func LOAD_Struct_from_FILE(FULL_path_2_file string, v interface{}, bequiet bool) error

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 MASTER_INIT(PROGNAME string, VERSION string, ALL_PARAMS ...string)

func MOST_RECENT_DATE

func MOST_RECENT_DATE(first time.Time, second time.Time) bool

If first is more recent than second, we return true

func NEW_UUID

func NEW_UUID() string

func NO_EXTRA_Spaces

func NO_EXTRA_Spaces(input string) string

This removes all extra spaces in a string

func OPEN_FILE

func OPEN_FILE(path_to_file string) *os.File

Opens a file and returns a file object

func PAD_STRING

func PAD_STRING(input string, TOTAL_FINAL_LEN int, ALL_PARAMS ...string) 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 PROMPT

func PROMPT(warning_TEXT string, required_input 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 PressAny

func PressAny(ALL_PARAMS ...interface{})

Simple PressAny Key function

func REMOVE_from_LIST

func REMOVE_from_LIST[T any](slice []T, s int) []T

func RUN_COMMAND

func RUN_COMMAND(command_text string, ALL_PARAMS ...string) (string, []string)
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

func SAVE_Struct_2_DISK(dest_file string, v interface{}) error

EXTRA_ARGS ...interface{}) {

var have_alt, alt_val = GET_EXTRA_ARG(0,  EXTRA_ARGS...)
var verbose, _  = GET_EXTRA_ARG("verbose", EXTRA_ARGS...)

func SHOW_BOX

func SHOW_BOX(ALL_PARAMS ...string)

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

func SHOW_PRETTY_DATE(input_DATE time.Time, EXTRA_ARGS ...string) (string, string)

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

func SHUFFLE_STRING(input_STRING string) 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_FLOAT(input string) float64

func STRING_to_FLOAT32

func STRING_to_FLOAT32(input string) float32

func STRING_to_INT

func STRING_to_INT(input string) int

func STRING_to_INT64

func STRING_to_INT64(input string) int64

func ShowNum

func ShowNum(innum int) string

This utilizes the HUMANIZE library and shows a HUMAN readable number of the passed variable

func ShowNum64

func ShowNum64(innum int64) string

64bit version of this.. not sure why im using this yet

func ShowNum_FLOAT

func ShowNum_FLOAT(innum float64) string

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 Sleep

func Sleep(seconds int, ALL_PARAMS ...bool)

this is a simple sleep function

func TOUCH_FILE

func TOUCH_FILE(filename string)

func UNICODE_REMOVE_ALL_SPACES

func UNICODE_REMOVE_ALL_SPACES(str string) string

This removes all spaces from a string via unicode

func UpperFirst

func UpperFirst(inString string) string

Make sthe first character of a string UPPER CASE

func VERIFICATION_PROMPT

func VERIFICATION_PROMPT(warning_TEXT string, required_input string, ALL_PARAMS ...interface{}) bool

func WRITE_FILE

func WRITE_FILE(FULL_FILENAME string, TEXT_for_FILE string, ALL_PARAMS ...string) bool

Convenient way to write to a file. either append or overwrite

Types

type FILE_INFO_OBJ

type FILE_INFO_OBJ struct {
	NAME        string
	TYPE        string
	IS_DIR      bool
	IS_LINK     bool
	LINK_ORIGIN string

	PATH      string
	FULL_PATH string
	SIZE      float64
	DATE      string
	TIME      string
}

func GET_FILE_INFO

func GET_FILE_INFO(filename string) FILE_INFO_OBJ

type IP

type IP struct {
	Query string
}

Directories

Path Synopsis
APIce module
MDC module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL