{"id":22285522,"url":"https://github.com/shamaton/msgpackgen","last_synced_at":"2025-06-18T17:33:01.981Z","repository":{"id":43038515,"uuid":"321554471","full_name":"shamaton/msgpackgen","owner":"shamaton","description":"Extremely Fast MessagePack Serializer and Code Generator for Go. / msgpack.org[Go]","archived":false,"fork":false,"pushed_at":"2023-09-10T14:28:40.000Z","size":350,"stargazers_count":40,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-05T04:24:25.256Z","etag":null,"topics":["generator","go","golang","messagepack","msgpack","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/shamaton.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}},"created_at":"2020-12-15T04:39:33.000Z","updated_at":"2025-02-12T20:40:27.000Z","dependencies_parsed_at":"2022-08-12T10:11:17.192Z","dependency_job_id":null,"html_url":"https://github.com/shamaton/msgpackgen","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/shamaton/msgpackgen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shamaton%2Fmsgpackgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shamaton%2Fmsgpackgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shamaton%2Fmsgpackgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shamaton%2Fmsgpackgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shamaton","download_url":"https://codeload.github.com/shamaton/msgpackgen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shamaton%2Fmsgpackgen/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260598978,"owners_count":23034425,"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","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":["generator","go","golang","messagepack","msgpack","serializer"],"created_at":"2024-12-03T16:52:38.227Z","updated_at":"2025-06-18T17:32:56.964Z","avatar_url":"https://github.com/shamaton.png","language":"Go","readme":"# MessagePack Code Generator for Go\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/shamaton/msgpackgen.svg)](https://pkg.go.dev/github.com/shamaton/msgpackgen)\n![test](https://github.com/shamaton/msgpackgen/workflows/test/badge.svg)\n[![Go Report Card](https://goreportcard.com/badge/github.com/shamaton/msgpackgen)](https://goreportcard.com/report/github.com/shamaton/msgpackgen)\n[![codecov](https://codecov.io/gh/shamaton/msgpackgen/branch/main/graph/badge.svg?token=K7M3778X7C)](https://codecov.io/gh/shamaton/msgpackgen)\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fshamaton%2Fmsgpackgen.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fshamaton%2Fmsgpackgen?ref=badge_shield)\n\n**msgpackgen** provides a code generation tool and serialization library for [MessagePack](http://msgpack.org/).\n\n* 🚀 Extremely Fast\n* ♻️ Easy Maintenance\n* 💯 Compliant with [specifications](https://github.com/msgpack/msgpack/blob/master/spec.md)\n\n## Quickstart\nCreate go.mod file, if you still have not created.\n\n```shell\n# example\ngo mod init github.com/user/awesome\n```\n\nIn a source file(ex. main.go), include the following directive:\n\n```go\n//go:generate msgpackgen\nor\n//go:generate go run github.com/shamaton/msgpackgen\n```\n\nAnd run the following command in your shell:\n\n```shell\ngo generate\n```\n\nIt will generate one `.go` file for serialization, default is `resolver.msgpackgen.go`.\nYou can call one method to use generated code.\n\n```go\nfunc main() {\n\t// this method is defined in resolver.msgpackgen.go\n\tRegisterGeneratedResolver()\n\t\n\t// ... your code ...\n}\n```\n\n`Marshal` and `Unmarshal` look like this:\n```go\n    // import github.com/shamaton/msgpackgen/msgpack\n    v := ResolvedStruct{}\n    b, err := msgpack.Marshal(v)\n    if err != nil {\n        panic(err)\n    }\n    \n    var vv ResolvedStruct\n    err = msgpack.Unmarshal(b, \u0026vv)\n    if err != nil {\n        panic(err)\n    }\n```\n\n## Serializer\n### Supported Types\nprimitive types:  \n`int`, `int8`, `int16`, `int32`, `int64`,\n`uint`, `uint8`, `uint16`, `uint32`, `uint64`,\n`float32`, `float64`, `string`, `bool`, `byte`, `rune`,\n`complex64`, `complex128`\n\nslice, array: `[]`, `[cap]`\n\nmap: `map[key]value`\n\nstruct: `time.Time` and structures you defined\n\n### Tags\nRenaming or omitting are available.\n\n* Renaming fields via `msgpack:\"field_name\"`\n* Omitting fields via `msgpack:\"-\"`\n\n\n### Switch Default Behaviour\nDefault serialization behaviour is map type. But the performance of array type is better.\nIf you want to switch array type as default, use `SetStructAsArray`.\n\nAlso, you can use `MarshalAsArray`, `UnmarshalAsArray`.\n\n## Code Generator\n### Easy maintenance\nThis tool generates only one `.go` file.\nAll you have to delete is one generated `.go` file. \n\n### Analyzing\n`-input-dir` needs to be in $GOPATH.\n\nResolver is generated by recursively searching directories,\nbut some directories and files are ignored.\n* Prefix `_` and `.` directory.\n* `testdata` and `vendor` directory\n* `_test.go` file\n\nIf you use `-input-file` option, it will work without considering the above conditions.\n\n---\n\nCompatible with various import rules.\n\n```go\nimport (\"\n\t\"example.com/user/a/b\"\n\td \"example.com/user/a/c\"\n\t. \"example.com/user/a/e\"\n)\n```\n\n### Not Generated Case\nNot generated in the following cases:\n\n```go\n// ex. a/example.go\ntype Example struct {\n\t// unsupported types\n\tInterface interface{}\n\tUintptr uintptr\n\tError error\n\tChan chan\n\tFunc func()\n\t\n\t// nested struct is also unsupported\n\tNestedStruct struct {}\n\t\n\t// because b.Example is not generated\n\tB b.Example\n\t\n\t// because bytes.Butffer is in outside package\n\tBuf bytes.Buffer\n}\n\nfunc (e Example) F() {\n\t// unsupported  struct defined in func\n\ttype InFunction struct {}\n}\n\n// ex a/b/example.go\ntype Example struct {\n\tInterface interface{}\n}\n```\nIf you serialize a struct that wasn't code generated, it will be processed by [shamaton/msgpack](https://github.com/shamaton/msgpack).\n\n### Strict Mode\nIf you use strict mode(option `-strict`), you will get an error if an unrecognized structure is passed.\nIn other words,  [shamaton/msgpack](https://github.com/shamaton/msgpack) is not used.\n\n---\n\nSee also `msgpackgen -h`\n```shell\nUsage of msgpackgen:\n  -dry-run\n        dry run mode\n  -input-dir string\n        input directory. input-file cannot be used at the same time (default \".\")\n  -input-file string\n        input a specific file. input-dir cannot be used at the same time\n  -output-dir string\n        output directory (default \".\")\n  -output-file string\n        name of generated file (default \"resolver.msgpackgen.go\")\n  -pointer int\n        pointer level to consider (default 1)\n  -strict\n        strict mode\n  -use-gopath\n        use GOPATH instead of go.mod\n  -v    verbose diagnostics\n```\n\n## Benchmarks\n\nThese results are recorded by [msgpack_bench](https://github.com/shamaton/msgpack_bench) at 2021/08.  \nThe result of this package is that the suffix has `ShamatonGen`.\n![msgpack_bench](https://user-images.githubusercontent.com/4637556/128298988-0e3c96fd-6014-42a0-9050-36e2b58316b1.png)\nThe result of [go_serialization_benchmarks](https://github.com/alecthomas/go_serialization_benchmarks) is here.\n![go_serialization_benchmarks](https://user-images.githubusercontent.com/4637556/128299037-06b3a645-2726-4205-848a-cccebb9a3d7f.png)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshamaton%2Fmsgpackgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshamaton%2Fmsgpackgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshamaton%2Fmsgpackgen/lists"}