db_common

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsJSON added in v0.2.0

func IsJSON(b []byte) (bool, error)

func IsUTF16LE added in v0.2.0

func IsUTF16LE(data []byte, n int) bool

isUTF16LE checks if the first n bytes of a byte array are valid UTF-16 little-endian.

Since UTF-16 characters can be 2 or 4 bytes long (due to surrogate pairs), we need to be cautious with how many bytes we inspect to avoid cutting a character in half. For simplicity, We assume the UTF-16 encoding is little-endian, which is common, but we may need to add big-endian encoding check if required

TODO: this function isn't working as expected. It's returning true for blob data (most likely due to my misunderstanding of UTF-16)

func TryParseDataType added in v0.2.0

func TryParseDataType(data []byte) interface{}

MySQL driver always return a byte slice for all types

https://github.com/go-sql-driver/mysql/issues/407

For dynamic query type, we can only do a best effort approximation of the type

Types

This section is empty.

Jump to

Keyboard shortcuts

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