{"id":50479377,"url":"https://github.com/poisnoir/mad-go","last_synced_at":"2026-06-01T16:04:07.597Z","repository":{"id":338915861,"uuid":"1155691897","full_name":"poisnoir/mad-go","owner":"poisnoir","description":null,"archived":false,"fork":false,"pushed_at":"2026-03-30T17:59:44.000Z","size":31,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-30T19:31:23.376Z","etag":null,"topics":["go","mad","serilization"],"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/poisnoir.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":"2026-02-11T19:49:34.000Z","updated_at":"2026-03-30T17:59:47.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/poisnoir/mad-go","commit_stats":null,"previous_names":["poisnoir/mad-go"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/poisnoir/mad-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poisnoir%2Fmad-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poisnoir%2Fmad-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poisnoir%2Fmad-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poisnoir%2Fmad-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/poisnoir","download_url":"https://codeload.github.com/poisnoir/mad-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poisnoir%2Fmad-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33782317,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"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":["go","mad","serilization"],"created_at":"2026-06-01T16:04:06.762Z","updated_at":"2026-06-01T16:04:07.581Z","avatar_url":"https://github.com/poisnoir.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mad - High-Performance Serialization Library for Go\n\nMad is a Go serialization library that uses unsafe pointers for high-performance encoding and decoding of Go data structures. It supports various primitive types, strings, arrays, and structs with deterministic field ordering.\n\n## Features\n\n- **High Performance**: Uses unsafe pointers for direct memory access\n- **Type Safety**: Generic interface with compile-time type checking  \n- **Deterministic Encoding**: Struct fields are sorted alphabetically for consistent output\n- **Zero Allocation Decoding**: Direct memory manipulation for maximum performance\n\n## Supported Types\n\n- **Integers**: `int8`, `uint8`, `int16`, `uint16`, `int32`, `uint32`, `int64`, `uint64`\n- **Floating Point**: `float32`, `float64`\n- **Boolean**: `bool`\n- **Strings**: `string` (with 4-byte length prefix)\n- **Arrays**: Fixed-size arrays of supported types\n- **Structs**: Composite types with supported field types\n\n## Basic Usage\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/poisnoir/mad\"\n)\n\nfunc main() {\n    // Create a new encoder/decoder for int32\n    m, err := mad.NewMad[int32]()\n    if err != nil {\n        panic(err)\n    }\n    \n    // Encode a value\n    value := int32(42)\n    buffer := make([]byte, 4)\n    \n    err = m.Encode(\u0026value, buffer)\n    if err != nil {\n        panic(err)\n    }\n    \n    // Decode the value\n    var decoded int32\n    err = m.Decode(buffer, \u0026decoded)\n    if err != nil {\n        panic(err)\n    }\n    \n    fmt.Printf(\"Original: %d, Decoded: %d\\n\", value, decoded)\n}\n```\n\n## String Example\n\n```go\nfunc main() {\n    m, err := mad.NewMad[string]()\n    if err != nil {\n        panic(err)\n    }\n    \n    text := \"Hello, 世界!\"\n    \n    buffer := make([]byte, 30)\n    \n    // Encode\n    err = m.Encode(\u0026text, buffer)\n    if err != nil {\n        panic(err)\n    }\n    \n    // Decode\n    var decoded string\n    err = m.Decode(buffer, \u0026decoded)\n    if err != nil {\n        panic(err)\n    }\n    \n    fmt.Printf(\"Original: %s, Decoded: %s\\n\", text, decoded)\n}\n```\n\n## Struct Example\n\n```go\ntype Person struct {\n    Age    int32\n    Name   string\n    Score  float64\n    Active bool\n}\n\nfunc main() {\n    m, err := mad.NewMad[Person]()\n    if err != nil {\n        panic(err)\n    }\n    \n    person := Person{\n        Age:    25,\n        Name:   \"Alice\",\n        Score:  95.5,\n        Active: true,\n    }\n    \n    // Calculate required buffer size\n    size := m.GetRequiredSize(\u0026person)\n    buffer := make([]byte, size)\n    \n    // Encode\n    err = m.Encode(\u0026person, buffer)\n    if err != nil {\n        panic(err)\n    }\n    \n    // Decode\n    var decoded Person\n    err = m.Decode(buffer, \u0026decoded)\n    if err != nil {\n        panic(err)\n    }\n    \n    fmt.Printf(\"Original: %+v\\nDecoded:  %+v\\n\", person, decoded)\n}\n```\n\n## Performance\n\nMad achieves excellent performance through unsafe pointer operations:\n\n```\nBenchmarkEncodeInt32-24     \t40,738,098\t    29.63 ns/op\nBenchmarkDecodeInt32-24     \t44,280,801\t    25.03 ns/op\nBenchmarkEncodeString-24    \t39,330,438\t    30.53 ns/op\nBenchmarkDecodeString-24    \t25,965,541\t    42.58 ns/op\n```\n\n## Error Handling\n\nMad provides comprehensive error checking:\n\n- **Buffer Size Validation**: All encoders and decoders validate buffer sizes\n- **Type Safety**: Unsupported types return clear error messages\n- **Bounds Checking**: Prevents buffer overflows and underflows\n\n```go\n// Example error handling\nm, err := mad.NewMad[int64]()\nif err != nil {\n    // Handle unsupported type\n}\n\nsmallBuffer := make([]byte, 4) // int64 needs 8 bytes\nvalue := int64(12345)\nerr = m.Encode(\u0026value, smallBuffer)\nif err != nil {\n    // Handle \"output buffer too small\" error\n}\n```\n\n## Current Limitations\nMad decoder assumes the data is receiving is not corrupted and the only check is for buffer size.\n- **Slices**: Not supported\n- **Maps**: Not supported\n\n## Field Ordering\n\nStruct fields are encoded in alphabetical order by field name, ensuring deterministic output:\n\n```go\ntype Example struct {\n    Zebra string  // Encoded last\n    Alpha int32   // Encoded first  \n    Beta  bool    // Encoded second\n}\n```\n\n## Building and Testing\n\n```bash\n# Initialize module\ngo mod init github.com/poisnoir/mad\n\n# Run all tests\ngo test -v\n\n# Run benchmarks\ngo test -bench=.\n\n# Test specific functionality\ngo test -v -run TestStringEncoding\ngo test -v -run TestBufferValidation\n```\n\n## Installation\n\n```bash\ngo get github.com/poisnoir/mad-go\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoisnoir%2Fmad-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpoisnoir%2Fmad-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoisnoir%2Fmad-go/lists"}