decimal

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: BSD-2-Clause Imports: 6 Imported by: 3

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"
dialer := tarantool.NetDialer{
	Address:  server,
	User:     "test",
	Password: "test",
}
opts := tarantool.Opts{
	Timeout: 5 * time.Second,
}
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
client, err := tarantool.Connect(ctx, dialer, opts)
cancel()
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)
}

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

log.Println("Decimal tuple replace")
log.Println("Error", err)
log.Println("Data", 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