Help us shape the future of Go! Take the 2026 Go Developer Survey

convert

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package convert holds small generic adapters between the ogen-generated Opt*/OptNil* option types and the plain Go pointers that ent setters expect. They replace the per-package optNil* helpers that the site and external API handlers previously duplicated.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DocJSON

func DocJSON[M ~map[string]jx.Raw](fields M, set bool) json.RawMessage

DocJSON is the opaque editor-document object of a write as the JSON the modules render; nil when the request names none. An empty object is a document (an invalid one), not an absent one.

func DocObject

func DocObject[M ~map[string]jx.Raw](doc json.RawMessage) M

DocObject is a stored editor document as the opaque object of a contract; nil for a message written as HTML, which has none.

func Int64Ptr

func Int64Ptr[T ~int64, O getter[T]](o O) *int64

Int64Ptr is like Ptr but coerces named int64 option values (e.g. an EntityId) down to *int64, the type ent's Nillable setters take.

func Ptr

func Ptr[T any, O getter[T]](o O) *T

Ptr returns a pointer to the option's value, or nil when it is unset/null.

func RawMap

func RawMap[M ~map[string]jx.Raw](m M) map[string]any

RawMap decodes an ogen Record<unknown> body (map of raw JSON values) into a plain map[string]any so value types match what the service layer expects (float64 for numbers, bool, nested maps, …). Used for typed custom field values on the wire.

func StringPtr

func StringPtr[T ~string, O getter[T]](o O) *string

StringPtr is like Ptr but coerces named string option values (e.g. a TimeZoneName scalar) down to *string, the type ent's Nillable setters take.

Types

This section is empty.

Jump to

Keyboard shortcuts

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