# README
GoCryptoTrader package Common

This common package is part of the GoCryptoTrader codebase.
This is still in active development
You can track ideas, planned features and what's in progress on our GoCryptoTrader Kanban board.
Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack
Current Features for common
This package collates basic broad functions that are used throughout this codebase.
- Coding example
import "github.com/thrasher-corp/gocryptotrader/common"
testString := "aAaAa"
upper := strings.ToUpper(testString)
// upper == "AAAAA"
Please click GoDocs chevron above to view current GoDoc information for this package
Contribution
Please feel free to submit any pull requests or suggest any desired features to be added.
When submitting a PR, please abide by our coding guidelines:
- Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
- Code must be documented adhering to the official Go commentary guidelines.
- Code must adhere to our coding style.
- Pull requests need to be based on and opened against the
master
branch.
Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc
# Functions
AddPaddingOnUpperCase adds padding to a string when detecting an upper case letter.
AppendError appends an error to a list of exesting errors Either argument may be: * A vanilla error * An error implementing Unwrap() []error e.g.
Batch takes a slice type and converts it into a slice of containing slices of length batchSize, and any remainder in the final batch batchSize <= 0 will return the entire input slice in one batch.
ChangePermission lists all the directories and files in an array.
CollectErrors returns an ErrorCollector with WaitGroup and Channel buffer set to n.
CreateDir creates a directory based on the supplied parameter.
EncodeURLValues concatenates url values onto a url string and returns a string.
ExcludeError returns a new error excluding any errors matching excl For a standard error it will either return the error unchanged or nil For an error which implements Unwrap() []error it will remove any errors matching excl and return the remaining errors or nil Any non-error messages and formatting from fmt.Errorf will be lost; This function is written for conditions.
ExtractHost returns the hostname out of a string.
ExtractPort returns the port name out of a string.
GenerateRandomString generates a random string provided a length and list of Character types { SmallLetters, CapitalLetters, NumberCharacters}.
GetDefaultDataDir returns the default data directory Windows - C:\Users\%USER%\AppData\Roaming\GoCryptoTrader Linux/Unix or OSX - $HOME/.gocryptotrader.
GetExecutablePath returns the executables launch path.
GetTypeAssertError returns additional information for when an assertion failure occurs.
GetURIPath returns the path of a URL given a URI.
IsEnabled takes in a boolean param and returns a string if it is enabled or disabled.
IsValidCryptoAddress validates your cryptocurrency address string using the regexp package // Validation issues occurring because "3" is contained in litecoin and Bitcoin addresses - non-fatal.
MatchesEmailPattern ensures that the string is an email address by regexp check.
NewHTTPClientWithTimeout initialises a new HTTP client and its underlying transport IdleConnTimeout with the specified timeout duration.
SendHTTPRequest sends a request using the http package and returns the body contents.
SetHTTPClient sets a custom HTTP client.
SetHTTPClientWithTimeout sets a new *http.Client with different timeout settings.
SetHTTPUserAgent sets the user agent which will be used for all common HTTP requests.
SliceDifference returns the elements that are in slice1 or slice2 but not in both.
SortStrings takes a slice of fmt.Stringer implementers and returns a new ascending sorted slice.
StartEndTimeCheck provides some basic checks which occur frequently in the codebase.
StringSliceCompareInsensitive returns whether case insensitive needle exists within haystack.
StringSliceContains returns whether case sensitive needle is contained within haystack.
StringSliceContainsInsensitive returns whether case insensitive needle is contained within haystack.
YesOrNo returns a boolean variable to check if input is "y" or "yes".
# Constants
Strings representing the full lower, upper case English character alphabet and base-10 numbers for generating a random string.
GctExt is the extension for GCT Tengo script files.
Strings representing the full lower, upper case English character alphabet and base-10 numbers for generating a random string.
SimpleTimeFormatWithTimezone a common, but non-implemented time format in golang.
Strings representing the full lower, upper case English character alphabet and base-10 numbers for generating a random string.
# Variables
Public common Errors.
Public common Errors.
Public common Errors.
Public common Errors.
Public common Errors.
Public common Errors.
Public common Errors.
Public common Errors.
Public common Errors.
Public common Errors.
Public common Errors.
Public common Errors.
Public common Errors.
Public common Errors.
Public common Errors.
Public common Errors.
# Structs
Counter is a thread-safe counter.
ErrorCollector allows collecting a stream of errors from concurrent go routines Users should call e.Wg.Done and send errors to e.C.