{"modulePath":"github.com/mutablelogic/go-sqlite","version":"v1.1.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package values\n\nPackage values converts values between Go and SQLite, of SQLite's five types: integers, floats, text, blobs and NULL. An implementation, such as package ncruces, adapts where SQLite gives values, such as a row's columns, to Value, and where it takes them, such as a statement's arguments, to Setter.\n\n## Functions\n\n```go\nfunc Any(v Value) any\n```\nAny returns the value as an int64, a float64, a string, a \\[]byte, or nil\n\n```go\nfunc Duration(v Value) (time.Duration, error)\n```\nDuration returns the value's duration: an integer, of nanoseconds, which Set writes, a float, of seconds, which SQLite's date and time arithmetic returns, such as (julianday(b) - julianday(a)) \\* 86400, or text, of Go's format, such as 1h30m, or of nanoseconds\n\n```go\nfunc Scan(v Value, dest any) error\n```\nScan scans a value which SQLite gives into a pointer, the first of these which it points to:\n\n  - a sql.Scanner, such as a uuid.UUID, scans Any of the value\n  - an any is Any of the value\n  - a pointer is nil when it's NULL, or else points to the value\n  - NULL is nil, for a slice or a map, the zero time, for a time.Time, and otherwise an error\n  - a time.Time, as Time reads it, or a time.Duration, as Duration does\n  - an array of bytes of a blob's length, such as the standard library's uuid.UUID, of the blob, unless it's an encoding.BinaryUnmarshaler\n  - an encoding.TextUnmarshaler, of text, or an encoding.BinaryUnmarshaler, of a blob, or whichever it is, when it isn't both\n  - a json.Unmarshaler, of its JSON\n  - a bool, an integer, a float, or a string, of named types too, which a number, or text which is one, fits, without overflowing\n  - a \\[]byte, or an array of bytes, such as a \\[16]byte, of its length\n  - a slice, an array, a map or a struct, of its JSON\n\n```go\nfunc Set(s Setter, value any) error\n```\nSet sets a Go value where SQLite takes it, the first of these which it is:\n\n  - nil, or a nil pointer, is NULL\n  - a driver.Valuer is its value, such as a uuid.UUID's text\n  - a time.Time is text, of RFC 3339, with nanoseconds, or NULL when it's zero\n  - a time.Duration is an integer, of nanoseconds\n  - a \\[]byte is a blob\n  - an encoding.TextMarshaler is its text, such as a netip.Addr's, or the standard library's uuid.UUID's, rather than its binary, when it's both, so it's compared and read as text\n  - an encoding.BinaryMarshaler is a blob\n  - a json.Marshaler is its JSON, as text\n  - a bool is 0 or 1, an integer, which is no larger than an int64, is an integer, a float is a float, and a string is text, of named types too\n  - a pointer is of its value\n  - an array of bytes, such as a \\[16]byte, is a blob\n  - a slice, an array, a map or a struct is its JSON, as text, such as \\[\"a\",\"b\"], which SQLite's json functions read, such as json\\_each\n\n```go\nfunc Time(v Value) (time.Time, error)\n```\nTime returns the value's time, as SQLite's date and time functions read them: text, of RFC 3339, or of YYYY-MM-DD HH:MM:SS, with optional fractions of a second and time zone, which is otherwise UTC, an integer, of seconds since the Unix epoch, or a float, of a Julian day\n\n## Types\n\n```go\ntype Setter interface {\n\tSetNull() error\n\tSetInt64(int64) error\n\tSetFloat(float64) error\n\tSetText(string) error\n\tSetBlob([]byte) error\n}\n```\nSetter is where SQLite takes a value, such as a statement's argument, or a function's result\n\n```go\ntype Type int\n```\nType is one of SQLite's types of value\n\n```go\nconst (\n\tNull Type = iota\n\tInteger\n\tFloat\n\tText\n\tBlob\n)\n```\n\n```go\nfunc (t Type) String() string\n```\n\n```go\ntype Value interface {\n\tType() Type\n\tInt64() int64\n\tFloat() float64\n\tText() string\n\tBlob() []byte\n}\n```\nValue is a value which SQLite gives, such as a row's column, or a function's argument. Its methods convert it, as SQLite does, such as an integer to text.\n\n","path":"github.com/mutablelogic/go-sqlite/values","name":"values","synopsis":"Package values converts values between Go and SQLite, of SQLite's five types: integers, floats, text, blobs and NULL.","isRedistributable":true}
