decimal

package
v2.0.0-...-2a4499d Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package decimal with support of Tarantool's decimal data type.

Decimal data type supported in Tarantool since 2.2.

Since: 1.7.0

See also:

Example

To enable support of decimal in msgpack with https://github.com/shopspring/decimal, import tarantool/decimal submodule.

server := "127.0.0.1:3013"
opts := tarantool.Opts{
	Timeout:       5 * time.Second,
	Reconnect:     1 * time.Second,
	MaxReconnects: 3,
	User:          "test",
	Pass:          "test",
}
client, err := tarantool.Connect(server, opts)
if err != nil {
	log.Fatalf("Failed to connect: %s", err.Error())
}

spaceNo := uint32(524)

number, err := MakeDecimalFromString("-22.804")
if err != nil {
	log.Fatalf("Failed to prepare test decimal: %s", err)
}

resp, err := client.Do(tarantool.NewReplaceRequest(spaceNo).
	Tuple([]interface{}{number}),
).Get()
if err != nil {
	log.Fatalf("Decimal replace failed: %s", err)
}
if resp == nil {
	log.Fatalf("Response is nil after Replace")
}

log.Println("Decimal tuple replace")
log.Println("Error", err)
log.Println("Code", resp.Code)
log.Println("Data", resp.Data)
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decimal

type Decimal struct {
	decimal.Decimal
}

func MakeDecimal

func MakeDecimal(decimal decimal.Decimal) Decimal

MakeDecimal creates a new Decimal from a decimal.Decimal.

func MakeDecimalFromString

func MakeDecimalFromString(src string) (Decimal, error)

MakeDecimalFromString creates a new Decimal from a string.

Jump to

Keyboard shortcuts

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