field-codecs

Transform database fields with custom codecs for JSON, GOB, or Unix time.

5|Updated Jun 18, 2026
One-click install
npx skills add https://github.com/go-again/liteorm --skill field-codecs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: field-codecs
Source: https://github.com/go-again/liteorm/tree/main/skills/field-codecs
Command: npx skills add https://github.com/go-again/liteorm --skill field-codecs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill helps address the challenge of transforming struct fields during database interactions, such as encryption or compression, without altering the Go type, ensuring both type safety and efficiency.

Core Features & Use Cases

  • Transparent Field Transformation: Encode/decode fields without altering the Go type or wrapping every read/write operation.
  • Codec Registration: Easily register custom codecs with a specific tag to transform data as needed.
  • Built-in Codecs: Utilize built-in codecs for JSON, GOB, and Unix Time.
  • Use Case: For example, storing an encrypted field with a []byte type without wrapping the entire field and affecting type safety.

Quick Start

Register a custom codec for field encryption using 'codec.Register("secretbox", codec.Func(...))' and tag the field 'orm:"value,codec:secretbox"'.

Frequently Asked Questions about field-codecs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I encrypt struct fields during database operations without changing the Go type?

Field transformation transparently encrypts struct fields during database interactions without altering the Go type. You register a custom codec and tag the field, ensuring type safety while encoding and decoding sensitive data on the fly.

Can I serialize JSON or GOB data transparently when writing to a database?

Yes, transparent JSON or GOB serialization is supported using built-in codecs. By registering the appropriate codec and tagging your struct field, data is automatically serialized when stored and deserialized when read, maintaining your original Go type.

How does codec registration work for custom database field transformations?

Codec registration involves defining a custom codec function and registering it with a specific tag name. You then apply this tag to your struct fields, enabling the automatic encoding and decoding of values during database reads and writes without manual wrapping.

What is the best way to store Unix timestamps in a database without altering my struct's time type?

Using a built-in Unix Time codec is the best way to handle Unix timestamp conversion. It automatically transforms your time fields to and from Unix timestamps in the database, maintaining type safety and efficiency without altering your Go struct's time type.

Does this field transformation approach affect type safety or require wrapping read and write operations?

No, this approach maintains type safety and eliminates the need to wrap every read or write operation. It transparently transforms values using registered codecs based on struct tags, keeping your original Go types clean and efficient.

When do I need a custom codec for database field encryption instead of built-in options?

You need a custom codec for database field encryption when utilizing specific encryption algorithms not covered by built-in options. Defining and registering a custom codec function allows you to apply specialized encryption logic to your struct fields transparently.