{"id":31259990,"url":"https://github.com/kivigo/encoders","last_synced_at":"2026-04-14T00:01:59.984Z","repository":{"id":314659072,"uuid":"1056324670","full_name":"kivigo/encoders","owner":"kivigo","description":"Pluggable encoders for KiviGo — a Go module providing JSON, YAML and extensible encoder interfaces for serializing values in key‑value backends","archived":false,"fork":false,"pushed_at":"2025-09-21T20:03:25.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-21T21:29:25.103Z","etag":null,"topics":["json","kivigo","yaml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kivigo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-13T21:06:23.000Z","updated_at":"2025-09-21T19:55:36.000Z","dependencies_parsed_at":"2025-09-13T22:27:17.043Z","dependency_job_id":"98b648c5-6d73-42fc-8567-7a1d70740533","html_url":"https://github.com/kivigo/encoders","commit_stats":null,"previous_names":["kivigo/encoders"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/kivigo/encoders","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kivigo%2Fencoders","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kivigo%2Fencoders/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kivigo%2Fencoders/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kivigo%2Fencoders/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kivigo","download_url":"https://codeload.github.com/kivigo/encoders/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kivigo%2Fencoders/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276545728,"owners_count":25661361,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-23T02:00:09.130Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","kivigo","yaml"],"created_at":"2025-09-23T08:45:32.655Z","updated_at":"2025-10-10T19:39:49.773Z","avatar_url":"https://github.com/kivigo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg align=\"left\" width=\"140\" src=\"https://kivigo.github.io/img/logo-kivigo.png\" alt=\"KiviGo Logo\" /\u003e\n\n# KiviGo — Encoders\n\nPluggable encoders for KiviGo. This small Go module provides a simple `Encoder` interface and ready-to-use implementations (JSON, YAML) so values can be serialized/deserialized consistently across KiviGo backends.\n\n## Features\n\n- Small and dependency-light encoder interface\n- Built-in implementations:\n  - JSON encoder\n  - YAML encoder\n- Easy to implement custom encoders (e.g. MsgPack, Gob, etc)\n- Unit tested and CI-friendly\n\n## Installation\n\n```sh\ngo get github.com/kivigo/encoders/\u003cencoder_name\u003e\n```\n\n## Included encoders\n\n- [`encoders/json`](https://pkg.go.dev/github.com/kivigo/encoders/json) — JSON encoder using `encoding/json` *(**Dependency-free**, default)*\n- [`encoders/yaml`](https://pkg.go.dev/github.com/kivigo/encoders/yaml) — YAML encoder using [`github.com/goccy/go-yaml`](https://github.com/goccy/go-yaml)\n- [`encoders/encrypt`](https://pkg.go.dev/github.com/kivigo/encoders/encrypt) — Encrypt encoder using [:heartbeat: `github.com/azrod/cryptio`](https://github.com/azrod/cryptio). Wrapper to encrypt/decrypt data using any other encoder (e.g. JSON + encryption)\n- [`encoders/compress`](https://pkg.go.dev/github.com/kivigo/encoders/compress) — Compression wrapper using various algorithms (LZ4, Gzip, custom). Each compression algorithm is released separately to keep dependencies minimal. Wrapper to compress/decompress data using any other encoder (e.g. JSON + compression or JSON + compression + encryption). You can write your own compression algorithm by implementing the [`model.Compressor`](https://pkg.go.dev/github.com/kivigo/encoders@main/model#Compressor) interface.\n  - [`encoders/compress/gzip`](https://pkg.go.dev/github.com/kivigo/encoders/compress/gzip) — Gzip compression using `compress/gzip` *(**Dependency-free**)*\n\n## Encoder interface\n\nImplementations must satisfy a small interface used by the KiviGo client:\n\n```go\npackage model\n\nimport \"context\"\n\n// Encoder defines how values are serialized and deserialized when stored or retrieved from a backend in KiviGo.\n//\n// KiviGo uses encoders to convert Go values (structs, strings, etc.) into a byte slice for storage,\n// and to decode byte slices back into Go values when reading from the backend.\n// This allows you to use different formats (JSON, YAML, etc.) or implement your own encoding logic.\n//\n// Example: using the JSON encoder, a struct will be marshaled to JSON before being saved in the database.\ntype Encoder interface {\n    // Encode serializes the given value into a byte slice.\n    //\n    // Example:\n    //   data, err := encoder.Encode(\"hello world\")\n    //   if err != nil {\n    //       log.Fatal(err)\n    //   }\n    //   fmt.Println(\"Encoded:\", data)\n    Encode(ctx context.Context, v any) ([]byte, error)\n\n    // Decode deserializes the given byte slice into the provided destination.\n    //\n    // Example:\n    //   var s string\n    //   err := encoder.Decode([]byte(`\"hello world\"`), \u0026s)\n    //   if err != nil {\n    //       log.Fatal(err)\n    //   }\n    //   fmt.Println(\"Decoded:\", s)\n    Decode(ctx context.Context, data []byte, v any) error\n}\n\n\n```\n\n## Usage with KiviGo\n\nUse an encoder when creating the KiviGo client (example with JSON):\n\n```go\nimport (\n    \"context\"\n    \"github.com/kivigo/kivigo\"\n    \"github.com/kivigo/encoders/json\"\n    \"github.com/kivigo/kivigo/backend/local\"\n)\n\nfunc example() error {\n    bk, err := local.New(local.DefaultOptions(\"/tmp/data\"))\n    if err != nil { return err }\n\n    c, err := kivigo.New(bk, kivigo.Option{Encoder: json.New()})\n    if err != nil { return err }\n    defer c.Close()\n\n    if err := c.Set(context.Background(), \"key\", map[string]string{\"foo\":\"bar\"}); err != nil {\n        return err\n    }\n    return nil\n}\n```\n\n## Writing a custom encoder\n\nCreate a type that implements `Encoder` and pass it to the client via `kivigo.Option{Encoder: myEncoder}`. Keep operations context-aware and error-returning.\n\n## Tests\n\nRun unit tests:\n\n```sh\ngo test ./...\n```\n\n## Contributing\n\n- Follow the project coding \u0026 testing guidelines\n- Add unit tests for new encoders\n- Document encoder-specific quirks in a short README or the project docs\n\n## License\n\nMozilla Public License v2.0. See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkivigo%2Fencoders","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkivigo%2Fencoders","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkivigo%2Fencoders/lists"}