decimal

package
v2.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: BSD-2-Clause Imports: 6 Imported by: 3 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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)

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