{"id":39164998,"url":"https://github.com/nazarifard/fastape","last_synced_at":"2026-01-28T09:21:23.253Z","repository":{"id":243808376,"uuid":"813505074","full_name":"nazarifard/fastape","owner":"nazarifard","description":"fast tape data serializer Go module","archived":false,"fork":false,"pushed_at":"2025-02-18T23:57:47.000Z","size":9171,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-18T06:57:21.400Z","etag":null,"topics":["golang","marshal","marshalling","serializer"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nazarifard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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":"2024-06-11T08:07:31.000Z","updated_at":"2025-05-11T22:09:25.000Z","dependencies_parsed_at":"2024-06-11T09:44:14.719Z","dependency_job_id":"65951e02-9c23-44a1-a9f2-fbdd53d6efc3","html_url":"https://github.com/nazarifard/fastape","commit_stats":null,"previous_names":["nazarifard/fastape"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/nazarifard/fastape","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazarifard%2Ffastape","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazarifard%2Ffastape/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazarifard%2Ffastape/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazarifard%2Ffastape/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nazarifard","download_url":"https://codeload.github.com/nazarifard/fastape/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazarifard%2Ffastape/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28843629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T07:39:25.367Z","status":"ssl_error","status_checked_at":"2026-01-28T07:39:24.487Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["golang","marshal","marshalling","serializer"],"created_at":"2026-01-17T22:11:19.436Z","updated_at":"2026-01-28T09:21:23.240Z","avatar_url":"https://github.com/nazarifard.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fastape\n\nFastape is a Go serializer designed for maximum throughput and minimal allocations when you control both ends of the bytes.\n\nIt’s a great fit for in-memory databases, caches, and hot paths where you want:\n- Precise buffer sizing (`Sizeof`) to avoid reallocations.\n- Very fast encode/decode (`Roll`/`Unroll`).\n- Generated, type-specific codecs (no reflection at runtime).\n\nThis is not intended as a general-purpose, portable wire format. See Safety \u0026 Portability.\n\n## Quickstart (code generation)\n\nInstall the generator binary:\n\n```sh\ngo install github.com/nazarifard/fastape/cmd/fastape@latest\n```\n\nAnnotate the types you want to generate tapes for. The marker must be in its own comment group with a blank line before the type:\n\n```go\npackage example\n\nimport \"time\"\n\ntype MyString string\ntype MyTime time.Time\n\n// fastape:generate\n\ntype Info = []map[MyString][3]struct {\n\t*MyTime\n\tCount int\n}\n\n//go:generate fastape .\n```\n\nGenerate and use the tape:\n\n```sh\ngo generate ./...\n```\n\n```go\nvar src, dst Info\nvar tape InfoTape // generated into fastape_gen.go\n\nbuf := make([]byte, tape.Sizeof(src))\nn, err := tape.Roll(src, buf)\nif err != nil {\n\t// handle\n}\n\n_, err = tape.Unroll(buf[:n], \u0026dst)\nif err != nil {\n\t// handle\n}\n```\n\n## Core API\n\nEvery tape implements:\n\n```go\ntype Tape[V any] interface {\n\tSizeof(v V) int\n\tRoll(v V, bs []byte) (n int, err error)    // encode\n\tUnroll(bs []byte, v *V) (n int, err error) // decode\n}\n```\n\n`Sizeof` is the key: it enables exact preallocation so encode paths can be 0-alloc.\n\n## What gets generated\n\nThe generator emits a `...Tape` type for each annotated type, built from a small set of composable primitives:\n- `StringTape` for strings\n- `TimeTape` for `time.Time`\n- `PtrTape`, `SliceTape`, `MapTape` for containers\n- `UnitTape` for fixed-size values (fast, but has portability tradeoffs)\n- `NamedTape` wrappers for named/alias types\n\nComplex shapes are supported (examples are under `testing/fixtures`):\n- alias + named types\n- nested structs (including across packages)\n- pointers, arrays, slices, maps\n- `time.Time` and `type MyTime time.Time`\n- inline anonymous structs (including tags)\n\n## Safety \u0026 Portability (read this)\n\nFastape is optimized for trusted bytes and in-memory usage.\n\nTrusted bytes means: the data may represent user data, but no untrusted party can tamper with the encoded bytes (not hardened against malicious/corrupt input).\n\nPortability notes:\n- There is no defined endianness for numeric types: many primitives use `UnitTape`, which writes Go’s in-memory representation.\n- Fixed-size structs may also be encoded via raw memory for speed, which can include padding bytes.\n- `int`/`uint` sizes are architecture-dependent, so blobs may not be readable across 32-bit vs 64-bit builds.\n- Because `UnitTape` relies on Go’s in-memory representation, compatibility across Go versions/toolchains is not guaranteed.\n- Map encoding order is not stable (Go map iteration is randomized), so byte-for-byte determinism is not guaranteed.\n\nPractical takeaway:\n- For a single-machine database/cache where the same program reads what it wrote, this works well.\n- If you need a stable, portable file/wire format, Fastape is not that today.\n\n## Buffer and value pooling (optional)\n\nIf you want to reuse buffers and decoded values, `NewMarshalTap` composes a tape with pools:\n\n```go\ntap := fastape.NewMarshalTap(tape, valuePool)\nbuf, err := tap.Encode(v)\n// ...\ndecoded, _, err := tap.Decode(buf.Bytes())\ntap.Free(decoded)\nbuf.Free()\n```\n\n## CLI\n\nThe generator is a small CLI:\n\n```sh\nfastape [flags] \u003cdir\u003e\n```\n\nSupported flags:\n- `-tags`: build tags passed to the parser (when loading the package)\n- `-tapable`: also emit `Tape() fastape.Tape[T]` methods for generated types\n\n## Benchmarks\n\nSee `BENCHMARK.md` for local `go test -bench` snapshots and a goserbench comparison.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnazarifard%2Ffastape","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnazarifard%2Ffastape","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnazarifard%2Ffastape/lists"}