util

package
v1.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Timeout = 15 * time.Second

Timeout is a http request wait timeout

Functions

func BytesToString

func BytesToString(b []byte) string

BytesToString converts zero terminated byte array to string Whole array is used when there is no zero in the string

func CheckTxIsolation

func CheckTxIsolation(tx *sql.Tx, level string) error

CheckTxIsolation return nil if transaction isolation is "level"

func ClickHouseToDriverType

func ClickHouseToDriverType(psql string) interface{}

ClickHouseToDriverType converts mysql type names to sql driver type suitable for scan

func EscapeQuotes

func EscapeQuotes(s string, quote byte) string

EscapeQuotes escapes given quote by doubling it

func ExecSQL

func ExecSQL(d *sql.DB, query string, param ...interface{}) error

ExecSQL executes SQL query

func ExecTxSQL

func ExecTxSQL(tx *sql.Tx, query string, param ...interface{}) error

ExecTxSQL executes SQL query in given transaction

func HTTPGet

func HTTPGet(ctx context.Context, url string) (body []byte, err error)

HTTPGet helper which returns response as a byte array

func HTTPGetWithHeaders

func HTTPGetWithHeaders(_ context.Context, url string, headers map[string]string) (body []byte, err error)

HTTPGetWithHeaders helper which returns response as a byte array

func HTTPPostJSON

func HTTPPostJSON(url string, body string) error

HTTPPostJSON posts given JSON message to given URL

func HTTPPostJSONWithHeaders

func HTTPPostJSONWithHeaders(url string, body string, headers map[string]string) error

HTTPPostJSONWithHeaders posts given JSON message to given URL

func MySQLError

func MySQLError(err error, code uint16) bool

MySQLError checks if givens error is MySQL error with given code

func MySQLEscape

func MySQLEscape(backslash bool, s string) string

MySQLEscape returns escaped string escaping backslashes or duplicating single quotes, based on backslash parameter

func MySQLToDriverType

func MySQLToDriverType(mtype string, ftype string) interface{}

MySQLToDriverType converts mysql type names to sql driver type suitable for scan FIXME: Use sql.ColumnType.DatabaseType instead if this function if go1.8 is * used

func PostgresToDriverType

func PostgresToDriverType(psql string) interface{}

PostgresToDriverType converts mysql type names to sql driver type suitable for scan

func QueryRowSQL

func QueryRowSQL(d *sql.DB, query string, param ...interface{}) *sql.Row

QueryRowSQL executes SQL query which return single row

func QuerySQL

func QuerySQL(d *sql.DB, query string, param ...interface{}) (*sql.Rows, error)

QuerySQL executes SQL query

func QueryTxRowSQL

func QueryTxRowSQL(tx *sql.Tx, query string, param ...interface{}) *sql.Row

QueryTxRowSQL executes SQL query which return single row

func QueryTxSQL

func QueryTxSQL(tx *sql.Tx, query string, param ...interface{}) (*sql.Rows, error)

QueryTxSQL executes SQL query

func SortedGTIDString

func SortedGTIDString(set *gomysql.MysqlGTIDSet) string

SortedGTIDString convert GTID set into string, where UUIDs comes in lexicographically sorted order. The order is the same as in output of select @@global.gtid_executed

Types

This section is empty.

Jump to

Keyboard shortcuts

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