Categorygithub.com/invertedv/utilities
modulepackage
0.1.37
Repository: https://github.com/invertedv/utilities.git
Documentation: pkg.go.dev

# README

Utilities

Go Report Card godoc

Everybody has little functions that the find themselves writing ... and re-writing in different packages. Enough! I got tired of that, so I created a package for it.

You might find them useful, too.

plotly

Included are functions that work with the excellent Go Plotly project. Some of these are convenience functions -- structs to hold common plot parameters such as title. Others output plots in standard formats such as png and jpeg. These rely on the orca app. The steps to use this app on Linux are:

  1. Download the latest release of the AppImage.

  2. Put it somewhere safe.

  3. chmod +x

  4. make a symbolic link called "orca" in your path.

    orca requires FUSE. FUSE installation instructions are here

Note that --no-sandbox is added to orca per this thread.

# Functions

Aligner returns a slice of strings suitable for printing the two input slices.
Any2Date attempts to convert inVal to a date (time.Time).
Any2Float32 attempts to convert inVal to float32.
Any2Float64 attempts to convert inVal to float64.
Any2Int attempts to convert inVal to int.
Any2Int32 attempts to convert inVal to int32.
Any2Int64 attempts to convert inVal to int64.
No description provided by the author
No description provided by the author
No description provided by the author
BuildQuery replaces the placeholders with values placeholders have the form "?key".
Comparer compares xa and xb.
CopyFile copies sourceFile to destFile.
CopyFiles recursively copies files from fromDir to toDir.
DBExists returns an error if db does not exist.
DeDupeSlice removes duplicate entries of inSlc, sorting if sortReturn.
DropTable drops the table from ClickHouse.
Fig2File outputs a plotly figure to a graphics file (png, jpg, etc.) This func requires that orca be installed.
FileExists returns an error if "file" does not exist.
GetTTYecho reads a response from the TTY while echoing the user's typing.
GetTTYnoecho reads a response from the TTYgit without echoing the user's typing.
GTAny compares xa > xb.
Has returns true if needle is in haystack.
HTML2File produces an image file from a plotly html file This func requires that orca be installed.
LTAny returns x<y for select underlying types of "any".
MakeConnection establishes the connection to ClickHouse, supplying common options - host, user, password are what you think - maxMemory: maximum memory (bytes) for a query - maxGroupBy: maximum memory to use in a GROUP BY - maxThreads: maximum # of threads for a query.
Matched returns a substring that is between the outermost set of startChar/endChar.
MaxInt returns the maximum of ints.
MinInt returns the minimum of ints.
NewHistData pulls the data from ClickHouse and creates a plotly histogram.
NewQuantileData pulls the data from ClickHouse and creates a plotly quantile plot.
No description provided by the author
Pad pads each element of inTable so the columns line up with pad spaces separating them.
Plotter plots the Plotly Figure fig with Layout lay.
Position returns the index of needle in the haystack.
PrettyDur returns a run duration in a minutes/seconds format.
PrettyString returns a string version of x suitable for printing.
QueryToCSV writes the output of the query to a CSV.
RandNorm generates a slice whose elements are N(0,1).
RandomLetters generates a string of length "length" by randomly choosing from a-z.
RandUnifFlt generates a slice whose elements are random U(0, 1) floats.
RandUnifInt generates a slice whose elements are random U[0,upper) int64's.
ReplaceSmart replaces old with new except when it occurs within delim.
Slash adds a trailing slash if inStr doesn't end in a slash.
String2Kind converts a string specifying a type to the reflect.Kind.
TableExists returns an error if "table" does not exist.
TableOrQuery takes table and returns a query.
TempFile produces a random temp file name in the system's tmp location.
TempTable produces a random table name.
ToClickHouse returns a string suitable for a ClickHouse constant value.
ToFile writes string to file fileName, which is created.
ToLastDay moves a date to the last day of the month.
YesNo determines if inStr is yes/no, return true if "yes".

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

Browser is the browser in which to show plots.

# Structs

HistData represents a histogram constructed from querying ClickHouse.
PlotDef specifies Plotly Layout features I commonly use.
QuantileData represents a quantile plot constructed from querying ClickHouse.
Table holds a table.
No description provided by the author

# Type aliases

PlotlyImage is the type of image file to create.