Go · Installation

Installation

import "github.com/unum-cloud/uform" 4.0.0-rc.1 · c58749fe

Ask your coding agent about this page, or add the docs server to it

curl -s 'https://www.unum.cloud/docs/uform/go/installation.md' | claude -p "How would this fit my code?"

The Go package is a cgo layer over the C library, fetched as a module:

go get github.com/unum-cloud/uform/golang@main

The package includes the headers of its own module’s c/ folder and links libuform_static, which you build from a checkout and name to cgo:

cmake --preset library && cmake --build --preset library --target uform_static
export CGO_LDFLAGS="-L$PWD/build_library/src -lturbojpeg -lpng -lwebp -lavformat -lavcodec -lavutil -lswresample -lswscale"

The archive carries UForm and its bundled libraries, while the system image, video and audio codecs its host decoders call stay shared libraries, which cgo links by name as Rust’s build.rs does; the stand-in needs none of them. -D UFORM_ENCODER_DTYPES=bf16 narrows the block-product dtypes the archive compiles from the default bf16;e4m3, and a model load in a left-out one fails with StatusUnsupported. EncoderDTypesCompiled() answers the kept ones as a mask, bit n standing for the Scalar valued n.

The module carries no version suffix, so pin a branch or a commit, @main or @<commit>, which go.sum locks as a pseudo-version. The suites run against the stand-in library, which answers every verb over the C++ standard library alone:

cmake --preset stub_library -D UFORM_WITH_CODECS=OFF && cmake --build --preset stub_library --target uform_static_stub
CGO_LDFLAGS="-L$PWD/build_stub_library/stub" go test -race ./golang/...

API

Functions

EncoderDTypesCompiledEncoderDTypesCompiled is the mask of block-product dtypes the linked encoder compiles, bit n standing for the Scalar valued n.
uform.go:1269 ↗
func EncoderDTypesCompiled() uint64
VersionVersion reports the version of the linked library.
uform.go:1261 ↗
func Version() string