common

package
v0.0.0-...-1ca2487 Latest Latest
Warning

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

Go to latest
Published: May 29, 2020 License: MIT Imports: 17 Imported by: 0

README

GoCryptoTrader package Common

Build Status Software License GoDoc Coverage Status Go Report Card

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 this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

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

Documentation

Index

Constants

View Source
const (
	SatoshisPerBTC = 100000000
	SatoshisPerLTC = 100000000
	WeiPerEther    = 1000000000000000000
)

Const declarations for common.go operations

View Source
const SimpleTimeFormat = "2006-01-02 15:04:05"

SimpleTimeFormat a common, but non-implemented time format in golang

Variables

View Source
var (
	HTTPClient    *http.Client
	HTTPUserAgent string

	// ErrNotYetImplemented defines a common error across the code base that
	// alerts of a function that has not been completed or tied into main code
	ErrNotYetImplemented = errors.New("not yet implemented")

	// ErrFunctionNotSupported defines a standardised error for an unsupported
	// wrapper function by an API
	ErrFunctionNotSupported = errors.New("unsupported wrapper function")
)

Vars for common.go operations

Functions

func ChangePermission

func ChangePermission(directory string) error

ChangePermission lists all the directories and files in an array

func CreateDir

func CreateDir(dir string) error

CreateDir creates a directory based on the supplied parameter

func EncodeURLValues

func EncodeURLValues(urlPath string, values url.Values) string

EncodeURLValues concatenates url values onto a url string and returns a string

func ExtractHost

func ExtractHost(address string) string

ExtractHost returns the hostname out of a string

func ExtractPort

func ExtractPort(host string) int

ExtractPort returns the port name out of a string

func GetDefaultDataDir

func GetDefaultDataDir(env string) string

GetDefaultDataDir returns the default data directory Windows - C:\Users\%USER%\AppData\Roaming\GoCryptoTrader Linux/Unix or OSX - $HOME/.gocryptotrader

func GetExecutablePath

func GetExecutablePath() (string, error)

GetExecutablePath returns the executables launch path

func GetURIPath

func GetURIPath(uri string) string

GetURIPath returns the path of a URL given a URI

func InArray

func InArray(val, array interface{}) (exists bool, index int)

InArray checks if _val_ belongs to _array_

func IsEnabled

func IsEnabled(isEnabled bool) string

IsEnabled takes in a boolean param and returns a string if it is enabled or disabled

func IsValidCryptoAddress

func IsValidCryptoAddress(address, crypto string) (bool, error)

IsValidCryptoAddress validates your cryptocurrency address string using the regexp package // Validation issues occurring because "3" is contained in litecoin and Bitcoin addresses - non-fatal

func NewHTTPClientWithTimeout

func NewHTTPClientWithTimeout(t time.Duration) *http.Client

NewHTTPClientWithTimeout initialises a new HTTP client with the specified timeout duration

func OutputCSV

func OutputCSV(filePath string, data [][]string) error

OutputCSV dumps data into a file as comma-separated values

func SendHTTPGetRequest

func SendHTTPGetRequest(urlPath string, jsonDecode, isVerbose bool, result interface{}) error

SendHTTPGetRequest sends a simple get request using a url string & JSON decodes the response into a struct pointer you have supplied. Returns an error on failure.

func SendHTTPRequest

func SendHTTPRequest(method, urlPath string, headers map[string]string, body io.Reader) (string, error)

SendHTTPRequest sends a request using the http package and returns a response as a string and an error

func SplitStringSliceByLimit

func SplitStringSliceByLimit(in []string, limit uint) [][]string

SplitStringSliceByLimit splits a slice of strings into slices by input limit and returns a slice of slice of strings

func StringDataCompare

func StringDataCompare(haystack []string, needle string) bool

StringDataCompare data checks the substring array with an input and returns a bool

func StringDataCompareInsensitive

func StringDataCompareInsensitive(haystack []string, needle string) bool

StringDataCompareInsensitive data checks the substring array with an input and returns a bool irrespective of lower or upper case strings

func StringDataContains

func StringDataContains(haystack []string, needle string) bool

StringDataContains checks the substring array with an input and returns a bool

func StringDataContainsInsensitive

func StringDataContainsInsensitive(haystack []string, needle string) bool

StringDataContainsInsensitive checks the substring array with an input and returns a bool irrespective of lower or upper case strings

func StringSliceDifference

func StringSliceDifference(slice1, slice2 []string) []string

StringSliceDifference concatenates slices together based on its index and returns an individual string array

func YesOrNo

func YesOrNo(input string) bool

YesOrNo returns a boolean variable to check if input is "y" or "yes"

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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