{"id":26826729,"url":"https://github.com/hslam/code","last_synced_at":"2026-04-27T12:01:56.335Z","repository":{"id":55599260,"uuid":"225603297","full_name":"hslam/code","owner":"hslam","description":"Package code implements encoding and decoding in golang.","archived":false,"fork":false,"pushed_at":"2021-06-10T15:00:22.000Z","size":84,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T11:32:46.257Z","etag":null,"topics":["decoding","encoding","fast","go","golang"],"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/hslam.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":"2019-12-03T11:27:09.000Z","updated_at":"2021-06-10T15:00:24.000Z","dependencies_parsed_at":"2022-08-15T04:01:07.142Z","dependency_job_id":null,"html_url":"https://github.com/hslam/code","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/hslam/code","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fcode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fcode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fcode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fcode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hslam","download_url":"https://codeload.github.com/hslam/code/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fcode/sbom","scorecard":{"id":470868,"data":{"date":"2025-08-11","repo":{"name":"github.com/hslam/code","commit":"db5f483caa0289a35d3cc18bd711d2bce51254b7"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.6,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/17 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":2,"reason":"dependency not pinned by hash detected -- score normalized to 2","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/hslam/code/go.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/hslam/code/go.yml/master?enable=pin","Warn: downloadThenRun not pinned by hash: .github/workflows/go.yml:24","Warn: downloadThenRun not pinned by hash: .github/workflows/go.yml:39","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   1 out of   1 goCommand dependencies pinned","Info:   0 out of   2 downloadThenRun dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 26 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T13:52:05.185Z","repository_id":55599260,"created_at":"2025-08-19T13:52:05.186Z","updated_at":"2025-08-19T13:52:05.186Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32335297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"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":["decoding","encoding","fast","go","golang"],"created_at":"2025-03-30T11:30:44.923Z","updated_at":"2026-04-27T12:01:56.319Z","avatar_url":"https://github.com/hslam.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# code\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/hslam/code)](https://pkg.go.dev/github.com/hslam/code)\n[![Build Status](https://github.com/hslam/code/workflows/build/badge.svg)](https://github.com/hslam/code/actions)\n[![Go Report Card](https://goreportcard.com/badge/github.com/hslam/code)](https://goreportcard.com/report/github.com/hslam/code)\n[![GitHub release](https://img.shields.io/github/release/hslam/code.svg)](https://github.com/hslam/code/releases/latest)\n[![LICENSE](https://img.shields.io/github/license/hslam/code.svg?style=flat-square)](https://github.com/hslam/code/blob/master/LICENSE)\n\nPackage code implements encoding and decoding in golang.\n\n## Feature\n* Uint8\n* Uint16\n* Uint32\n* Uint64\n* Varint\n* Float32\n* Float64\n* Bool\n* String\n* Bytes\n* Uint8Slice\n* Uint16Slice\n* Uint32Slice\n* Uint64Slice\n* VarintSlice\n* Float32Slice\n* Float64Slice\n* BoolSlice\n* StringSlice\n* BytesSlice\n\n## Get started\n\n### Install\n```\ngo get github.com/hslam/code\n```\n### Import\n```\nimport \"github.com/hslam/code\"\n```\n### Usage\n#### Example\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/hslam/code\"\n)\n\nfunc main() {\n\tUint8()\n\tUint16()\n\tUint32()\n\tUint64()\n\tVarint()\n\tFloat32()\n\tFloat64()\n\tBool()\n\tString()\n\tBytes()\n\tUint8Slice()\n\tUint16Slice()\n\tUint32Slice()\n\tUint64Slice()\n\tVarintSlice()\n\tFloat32Slice()\n\tFloat64Slice()\n\tBoolSlice()\n\tStringSlice()\n\tBytesSlice()\n}\n\n//Uint8 Example\nfunc Uint8() {\n\tvar i uint8 = 128\n\tvar buf = make([]byte, code.MaxUint8Bytes(i))\n\tvar n uint64\n\tsize := code.SizeofUint8(i)\n\tfmt.Printf(\"SizeofUint8:%d sizeof:%d\\n\", i, size)\n\tn = code.EncodeUint8(buf, i)\n\tfmt.Printf(\"EncodeUint8:%d to []byte:%v\\n\", i, buf[:n])\n\tvar v uint8\n\tn = code.DecodeUint8(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeUint8:%d,length:%d\\n\", v, n)\n}\n\n//Uint16 Example\nfunc Uint16() {\n\tvar i uint16 = 128\n\tvar buf = make([]byte, code.MaxUint16Bytes(i))\n\tvar n uint64\n\tsize := code.SizeofUint16(i)\n\tfmt.Printf(\"SizeofUint16:%d sizeof:%d\\n\", i, size)\n\tn = code.EncodeUint16(buf, i)\n\tfmt.Printf(\"EncodeUint16:%d to []byte:%v\\n\", i, buf[:n])\n\tvar v uint16\n\tn = code.DecodeUint16(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeUint16:%d,length:%d\\n\", v, n)\n}\n\n//Uint32 Example\nfunc Uint32() {\n\tvar i uint32 = 128\n\tvar buf = make([]byte, code.MaxUint32Bytes(i))\n\tvar n uint64\n\tsize := code.SizeofUint32(i)\n\tfmt.Printf(\"SizeofUint32:%d sizeof:%d\\n\", i, size)\n\tn = code.EncodeUint32(buf, i)\n\tfmt.Printf(\"EncodeUint32:%d to []byte:%v\\n\", i, buf[:n])\n\tvar v uint32\n\tn = code.DecodeUint32(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeUint32:%d,length:%d\\n\", v, n)\n}\n\n//Uint64 Example\nfunc Uint64() {\n\tvar i uint64 = 128\n\tvar buf = make([]byte, code.MaxUint64Bytes(i))\n\tvar n uint64\n\tsize := code.SizeofUint64(i)\n\tfmt.Printf(\"SizeofUint64:%d sizeof:%d\\n\", i, size)\n\tn = code.EncodeUint64(buf, i)\n\tfmt.Printf(\"EncodeUint64:%d to []byte:%v\\n\", i, buf[:n])\n\tvar v uint64\n\tn = code.DecodeUint64(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeUint64:%d,length:%d\\n\", v, n)\n}\n\n//Varint Example\nfunc Varint() {\n\tvar i uint64 = 128\n\tvar buf = make([]byte, code.MaxVarintBytes(i))\n\tvar n uint64\n\tsize := code.SizeofVarint(i)\n\tfmt.Printf(\"SizeofVarint:%d sizeof:%d\\n\", i, size)\n\tn = code.EncodeVarint(buf, i)\n\tfmt.Printf(\"EncodeVarint:%d to []byte:%v\\n\", i, buf[:n])\n\tvar v uint64\n\tn = code.DecodeVarint(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeVarint:%d,length:%d\\n\", v, n)\n}\n\n//Float32 Example\nfunc Float32() {\n\tvar i float32 = 3.14\n\tvar buf = make([]byte, code.MaxFloat32Bytes(i))\n\tvar n uint64\n\tsize := code.SizeofFloat32(i)\n\tfmt.Printf(\"SizeofFloat32:%.2f sizeof:%d\\n\", i, size)\n\tn = code.EncodeFloat32(buf, i)\n\tfmt.Printf(\"EncodeFloat32:%.2f to []byte:%v\\n\", i, buf[:n])\n\tvar v float32\n\tn = code.DecodeFloat32(buf[:n], \u0026v)\n\tfmt.Printf(\"EncodeFloat32:%.2f,length:%d\\n\", v, n)\n}\n\n//Float64 Example\nfunc Float64() {\n\tvar i float64 = 3.1415926\n\tvar buf = make([]byte, code.MaxFloat64Bytes(i))\n\tvar n uint64\n\tsize := code.SizeofFloat64(i)\n\tfmt.Printf(\"SizeofFloat64:%.7f sizeof:%d\\n\", i, size)\n\tn = code.EncodeFloat64(buf, i)\n\tfmt.Printf(\"EncodeFloat64:%.7f to []byte:%v\\n\", i, buf[:n])\n\tvar v float64\n\tn = code.DecodeFloat64(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeFloat64:%.7f,length:%d\\n\", v, n)\n}\n\n//Bool Example\nfunc Bool() {\n\tvar i bool = true\n\tvar buf = make([]byte, code.MaxBoolBytes(i))\n\tvar n uint64\n\tsize := code.SizeofBool(i)\n\tfmt.Printf(\"SizeofBool:%t sizeof:%d\\n\", i, size)\n\tn = code.EncodeBool(buf, i)\n\tfmt.Printf(\"EncodeBool:%t to []byte:%v\\n\", i, buf[:n])\n\tvar v bool\n\tn = code.DecodeBool(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeBool:%t,length:%d\\n\", v, n)\n}\n\n//String Example\nfunc String() {\n\tvar i string = \"Hello\"\n\tvar buf = make([]byte, code.MaxStringBytes(i))\n\tvar n uint64\n\tsize := code.SizeofString(i)\n\tfmt.Printf(\"SizeofString:%s sizeof:%d\\n\", i, size)\n\tn = code.EncodeString(buf, i)\n\tfmt.Printf(\"EncodeString:%s to []byte:%v\\n\", i, buf[:n])\n\tvar v string\n\tn = code.DecodeString(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeString:%s,length:%d\\n\", v, n)\n}\n\n//Bytes Example\nfunc Bytes() {\n\tvar i []byte = []byte{1, 2}\n\tvar buf = make([]byte, code.MaxBytesBytes(i))\n\tvar n uint64\n\tsize := code.SizeofBytes(i)\n\tfmt.Printf(\"SizeofBytes:%v sizeof:%d\\n\", i, size)\n\tn = code.EncodeBytes(buf, i)\n\tfmt.Printf(\"EncodeBytes:%v to []byte:%v\\n\", i, buf[:n])\n\tvar v = make([]byte, 2)\n\tn = code.DecodeBytes(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeBytes:%v,length:%d\\n\", v, n)\n}\n\n//Uint8Slice Example\nfunc Uint8Slice() {\n\tvar i []uint8 = []uint8{128, 255}\n\tvar buf = make([]byte, code.MaxUint8SliceBytes(i))\n\tvar n uint64\n\tsize := code.SizeofUint8Slice(i)\n\tfmt.Printf(\"SizeofUint8Slice:%v sizeof:%d\\n\", i, size)\n\tn = code.EncodeUint8Slice(buf, i)\n\tfmt.Printf(\"EncodeUint8Slice:%v to []byte:%v\\n\", i, buf[:n])\n\tvar v = make([]uint8, 2)\n\tn = code.DecodeUint8Slice(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeUint8Slice:%v,length:%d\\n\", v, n)\n}\n\n//Uint16Slice Example\nfunc Uint16Slice() {\n\tvar i []uint16 = []uint16{128, 256}\n\tvar buf = make([]byte, code.MaxUint16SliceBytes(i))\n\tvar n uint64\n\tsize := code.SizeofUint16Slice(i)\n\tfmt.Printf(\"SizeofUint16Slice:%v sizeof:%d\\n\", i, size)\n\tn = code.EncodeUint16Slice(buf, i)\n\tfmt.Printf(\"EncodeUint16Slice:%v to []byte:%v\\n\", i, buf[:n])\n\tvar v = make([]uint16, 2)\n\tn = code.DecodeUint16Slice(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeUint16Slice:%v,length:%d\\n\", v, n)\n}\n\n//Uint32Slice Example\nfunc Uint32Slice() {\n\tvar i []uint32 = []uint32{128, 256}\n\tvar buf = make([]byte, code.MaxUint32SliceBytes(i))\n\tvar n uint64\n\tsize := code.SizeofUint32Slice(i)\n\tfmt.Printf(\"SizeofUint32Slice:%v sizeof:%d\\n\", i, size)\n\tn = code.EncodeUint32Slice(buf, i)\n\tfmt.Printf(\"EncodeUint32Slice:%v to []byte:%v\\n\", i, buf[:n])\n\tvar v = make([]uint32, 2)\n\tn = code.DecodeUint32Slice(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeUint32Slice:%v,length:%d\\n\", v, n)\n}\n\n//Uint64Slice Example\nfunc Uint64Slice() {\n\tvar i []uint64 = []uint64{128, 256}\n\tvar buf = make([]byte, code.MaxUint64SliceBytes(i))\n\tvar n uint64\n\tsize := code.SizeofUint64Slice(i)\n\tfmt.Printf(\"SizeofUint64Slice:%v sizeof:%d\\n\", i, size)\n\tn = code.EncodeUint64Slice(buf, i)\n\tfmt.Printf(\"EncodeUint64Slice:%v to []byte:%v\\n\", i, buf[:n])\n\tvar v = make([]uint64, 2)\n\tn = code.DecodeUint64Slice(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeUint64Slice:%v,length:%d\\n\", v, n)\n}\n\n//VarintSlice Example\nfunc VarintSlice() {\n\tvar i []uint64 = []uint64{128, 256}\n\tvar buf = make([]byte, code.MaxVarintSliceBytes(i))\n\tvar n uint64\n\tsize := code.SizeofVarintSlice(i)\n\tfmt.Printf(\"SizeofVarintSlice:%v sizeof:%d\\n\", i, size)\n\tn = code.EncodeVarintSlice(buf, i)\n\tfmt.Printf(\"EncodeVarintSlice:%v to []byte:%v\\n\", i, buf[:n])\n\tvar v = make([]uint64, 2)\n\tn = code.DecodeVarintSlice(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeVarintSlice:%v,length:%d\\n\", v, n)\n}\n\n//Float32Slice Example\nfunc Float32Slice() {\n\tvar i []float32 = []float32{3.14}\n\tvar buf = make([]byte, code.MaxFloat32SliceBytes(i))\n\tvar n uint64\n\tsize := code.SizeofFloat32Slice(i)\n\tfmt.Printf(\"SizeofFloat32Slice:%v sizeof:%d\\n\", i, size)\n\tn = code.EncodeFloat32Slice(buf, i)\n\tfmt.Printf(\"EncodeFloat32Slice:%v to []byte:%v\\n\", i, buf[:n])\n\tvar v = make([]float32, 2)\n\tn = code.DecodeFloat32Slice(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeFloat32Slice:%v,length:%d\\n\", v, n)\n}\n\n//Float64Slice Example\nfunc Float64Slice() {\n\tvar i []float64 = []float64{3.1415926}\n\tvar buf = make([]byte, code.MaxFloat64SliceBytes(i))\n\tvar n uint64\n\tsize := code.SizeofFloat64Slice(i)\n\tfmt.Printf(\"SizeofFloat64Slice:%v sizeof:%d\\n\", i, size)\n\tn = code.EncodeFloat64Slice(buf, i)\n\tfmt.Printf(\"EncodeFloat64Slice:%v to []byte:%v\\n\", i, buf[:n])\n\tvar v = make([]float64, 2)\n\tn = code.DecodeFloat64Slice(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeFloat64Slice:%v,length:%d\\n\", v, n)\n}\n\n//BoolSlice Example\nfunc BoolSlice() {\n\tvar i []bool = []bool{true, false}\n\tvar buf = make([]byte, code.MaxBoolSliceBytes(i))\n\tvar n uint64\n\tsize := code.SizeofBoolSlice(i)\n\tfmt.Printf(\"SizeofBoolSlice:%v sizeof:%d\\n\", i, size)\n\tn = code.EncodeBoolSlice(buf, i)\n\tfmt.Printf(\"EncodeBoolSlice:%v to []byte:%v\\n\", i, buf[:n])\n\tvar v = make([]bool, 2)\n\tn = code.DecodeBoolSlice(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeBoolSlice:%v,length:%d\\n\", v, n)\n}\n\n//StringSlice Example\nfunc StringSlice() {\n\tvar i []string = []string{\"Hello\", \"World\"}\n\tvar buf = make([]byte, code.MaxStringSliceBytes(i))\n\tvar n uint64\n\tsize := code.SizeofStringSlice(i)\n\tfmt.Printf(\"SizeofStringSlice:%v sizeof:%d\\n\", i, size)\n\tn = code.EncodeStringSlice(buf, i)\n\tfmt.Printf(\"EncodeStringSlice:%v to []byte:%v\\n\", i, buf[:n])\n\tvar v = make([]string, 2)\n\tn = code.DecodeStringSlice(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeStringSlice:%v,length:%d\\n\", v, n)\n}\n\n//BytesSlice Example\nfunc BytesSlice() {\n\tvar i [][]byte = [][]byte{{1, 2}, {3}}\n\tvar buf = make([]byte, code.MaxBytesSliceBytes(i))\n\tvar n uint64\n\tsize := code.SizeofBytesSlice(i)\n\tfmt.Printf(\"SizeofBytesSlice:%v sizeof:%d\\n\", i, size)\n\tn = code.EncodeBytesSlice(buf, i)\n\tfmt.Printf(\"EncodeBytesSlice:%v to []byte:%v\\n\", i, buf[:n])\n\tvar v = make([][]byte, 2)\n\tn = code.DecodeBytesSlice(buf[:n], \u0026v)\n\tfmt.Printf(\"DecodeBytesSlice:%v,length:%d\\n\", v, n)\n}\n```\n\n### Output\n```\nSizeofUint8:128 sizeof:1\nEncodeUint8:128 to []byte:[128]\nDecodeUint8:128,length:1\nSizeofUint16:128 sizeof:2\nEncodeUint16:128 to []byte:[128 0]\nDecodeUint16:128,length:2\nSizeofUint32:128 sizeof:4\nEncodeUint32:128 to []byte:[128 0 0 0]\nDecodeUint32:128,length:4\nSizeofUint64:128 sizeof:8\nEncodeUint64:128 to []byte:[128 0 0 0 0 0 0 0]\nDecodeUint64:128,length:8\nSizeofVarint:128 sizeof:2\nEncodeVarint:128 to []byte:[128 1]\nDecodeVarint:128,length:2\nSizeofFloat32:3.14 sizeof:4\nEncodeFloat32:3.14 to []byte:[195 245 72 64]\nEncodeFloat32:3.14,length:4\nSizeofFloat64:3.1415926 sizeof:8\nEncodeFloat64:3.1415926 to []byte:[74 216 18 77 251 33 9 64]\nDecodeFloat64:3.1415926,length:8\nSizeofBool:true sizeof:1\nEncodeBool:true to []byte:[1]\nDecodeBool:true,length:1\nSizeofString:Hello sizeof:6\nEncodeString:Hello to []byte:[5 72 101 108 108 111]\nDecodeString:Hello,length:6\nSizeofBytes:[1 2] sizeof:3\nEncodeBytes:[1 2] to []byte:[2 1 2]\nDecodeBytes:[1 2],length:3\nSizeofUint8Slice:[128 255] sizeof:3\nEncodeUint8Slice:[128 255] to []byte:[2 128 255]\nDecodeUint8Slice:[128 255],length:3\nSizeofUint16Slice:[128 256] sizeof:5\nEncodeUint16Slice:[128 256] to []byte:[2 128 0 0 1]\nDecodeUint16Slice:[128 256],length:5\nSizeofUint32Slice:[128 256] sizeof:9\nEncodeUint32Slice:[128 256] to []byte:[2 128 0 0 0 0 1 0 0]\nDecodeUint32Slice:[128 256],length:9\nSizeofUint64Slice:[128 256] sizeof:17\nEncodeUint64Slice:[128 256] to []byte:[2 128 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0]\nDecodeUint64Slice:[128 256],length:17\nSizeofVarintSlice:[128 256] sizeof:5\nEncodeVarintSlice:[128 256] to []byte:[2 128 1 128 2]\nDecodeVarintSlice:[128 256],length:5\nSizeofFloat32Slice:[3.14] sizeof:5\nEncodeFloat32Slice:[3.14] to []byte:[1 195 245 72 64]\nDecodeFloat32Slice:[3.14],length:5\nSizeofFloat64Slice:[3.1415926] sizeof:9\nEncodeFloat64Slice:[3.1415926] to []byte:[1 74 216 18 77 251 33 9 64]\nDecodeFloat64Slice:[3.1415926],length:9\nSizeofBoolSlice:[true false] sizeof:3\nEncodeBoolSlice:[true false] to []byte:[2 1 0]\nDecodeBoolSlice:[true false],length:3\nSizeofStringSlice:[Hello World] sizeof:13\nEncodeStringSlice:[Hello World] to []byte:[2 5 72 101 108 108 111 5 87 111 114 108 100]\nDecodeStringSlice:[Hello World],length:13\nSizeofBytesSlice:[[1 2] [3]] sizeof:6\nEncodeBytesSlice:[[1 2] [3]] to []byte:[2 2 1 2 1 3]\nDecodeBytesSlice:[[1 2] [3]],length:6\n```\n\n### Benchmark\ngo test -v -run=\"none\" -bench=. -benchtime=30s\n```\ngoos: darwin\ngoarch: amd64\npkg: github.com/hslam/code\nBenchmarkCheckBuffer-4            \t1000000000\t         0.617 ns/op\t414612.88 MB/s\nBenchmarkCodeUint8-4              \t1000000000\t         0.310 ns/op\t3229.52 MB/s\nBenchmarkCodeUint16-4             \t1000000000\t         0.310 ns/op\t6453.14 MB/s\nBenchmarkCodeUint32-4             \t1000000000\t         0.309 ns/op\t12937.68 MB/s\nBenchmarkCodeUint64-4             \t1000000000\t         0.310 ns/op\t25797.99 MB/s\nBenchmarkCodeVarint-4             \t1000000000\t         7.42 ns/op\t 269.70 MB/s\nBenchmarkBinaryVarint-4           \t1000000000\t         8.87 ns/op\t 225.47 MB/s\nBenchmarkCodeFloat32-4            \t1000000000\t         0.336 ns/op\t11888.17 MB/s\nBenchmarkCodeFloat64-4            \t1000000000\t         0.926 ns/op\t8643.01 MB/s\nBenchmarkCodeBool-4               \t1000000000\t         0.314 ns/op\t3185.92 MB/s\nBenchmarkCodeString-4             \t1000000000\t        10.9 ns/op\t 183.75 MB/s\nBenchmarkCodeBytes-4              \t1000000000\t        10.8 ns/op\t 184.66 MB/s\nBenchmarkCodeUint8Slice-4         \t1000000000\t        10.7 ns/op\t 186.36 MB/s\nBenchmarkCodeUint16Slice-4        \t1000000000\t         8.97 ns/op\t 334.55 MB/s\nBenchmarkCodeUint32Slice-4        \t1000000000\t        10.5 ns/op\t 474.01 MB/s\nBenchmarkCodeUint64Slice-4        \t1000000000\t        14.2 ns/op\t 634.65 MB/s\nBenchmarkCodeVarintSlice-4        \t1000000000\t        11.1 ns/op\t 179.58 MB/s\nBenchmarkCodeFloat32Slice-4       \t1000000000\t        12.8 ns/op\t 390.38 MB/s\nBenchmarkCodeFloat64Slice-4       \t1000000000\t        16.2 ns/op\t 555.53 MB/s\nBenchmarkCodeBoolSlice-4          \t1000000000\t         9.63 ns/op\t 207.60 MB/s\nBenchmarkCodeStringSlice-4        \t1000000000\t        30.3 ns/op\t 164.94 MB/s\nBenchmarkCodeBytesSlice-4         \t1000000000\t        30.0 ns/op\t 166.70 MB/s\nBenchmarkSizeofUint8-4            \t1000000000\t         0.310 ns/op\t3224.62 MB/s\nBenchmarkSizeofUint16-4           \t1000000000\t         0.321 ns/op\t6221.12 MB/s\nBenchmarkSizeofUint32-4           \t1000000000\t         0.310 ns/op\t12904.22 MB/s\nBenchmarkSizeofUint64-4           \t1000000000\t         0.309 ns/op\t25885.08 MB/s\nBenchmarkSizeofVarint-4           \t1000000000\t         0.313 ns/op\t6393.58 MB/s\nBenchmarkSizeofFloat32-4          \t1000000000\t         0.312 ns/op\t12834.91 MB/s\nBenchmarkSizeofFloat64-4          \t1000000000\t         0.310 ns/op\t25811.82 MB/s\nBenchmarkSizeofBool-4             \t1000000000\t         0.310 ns/op\t3227.18 MB/s\nBenchmarkSizeofString-4           \t1000000000\t         0.314 ns/op\t3184.25 MB/s\nBenchmarkSizeofBytes-4            \t1000000000\t         0.312 ns/op\t3207.41 MB/s\nBenchmarkSizeofUint8Slice-4       \t1000000000\t         0.310 ns/op\t3220.83 MB/s\nBenchmarkSizeofUint16Slice-4      \t1000000000\t         0.311 ns/op\t3210.29 MB/s\nBenchmarkSizeofUint32Slice-4      \t1000000000\t         0.312 ns/op\t3205.69 MB/s\nBenchmarkSizeofUint64Slice-4      \t1000000000\t         0.309 ns/op\t3232.42 MB/s\nBenchmarkSizeofVarintSlice-4      \t1000000000\t         3.07 ns/op\t 325.79 MB/s\nBenchmarkSizeofFloat32Slice-4     \t1000000000\t         0.310 ns/op\t12901.08 MB/s\nBenchmarkSizeofFloat64Slice-4     \t1000000000\t         0.311 ns/op\t25684.42 MB/s\nBenchmarkSizeofBoolSlice-4        \t1000000000\t         0.312 ns/op\t3205.72 MB/s\nBenchmarkSizeofStringSlice-4      \t1000000000\t         3.16 ns/op\t 632.50 MB/s\nBenchmarkSizeofBytesSlice-4       \t1000000000\t         4.01 ns/op\t 498.30 MB/s\nBenchmarkMaxUint8Bytes-4          \t1000000000\t         0.313 ns/op\t3194.00 MB/s\nBenchmarkMaxUint16Bytes-4         \t1000000000\t         0.310 ns/op\t6460.12 MB/s\nBenchmarkMaxUint32Bytes-4         \t1000000000\t         0.311 ns/op\t12854.70 MB/s\nBenchmarkMaxUint64Bytes-4         \t1000000000\t         0.310 ns/op\t25837.95 MB/s\nBenchmarkMaxVarintBytes-4         \t1000000000\t         0.312 ns/op\t6415.42 MB/s\nBenchmarkMaxFloat32Bytes-4        \t1000000000\t         0.309 ns/op\t12946.37 MB/s\nBenchmarkMaxFloat64Bytes-4        \t1000000000\t         0.310 ns/op\t25809.76 MB/s\nBenchmarkMaxBoolBytes-4           \t1000000000\t         0.313 ns/op\t3193.68 MB/s\nBenchmarkMaxStringBytes-4         \t1000000000\t         0.311 ns/op\t3214.47 MB/s\nBenchmarkMaxBytesBytes-4          \t1000000000\t         0.310 ns/op\t3226.55 MB/s\nBenchmarkMaxUint8SliceBytes-4     \t1000000000\t         0.311 ns/op\t3210.37 MB/s\nBenchmarkMaxUint16SliceBytes-4    \t1000000000\t         0.312 ns/op\t3210.11 MB/s\nBenchmarkMaxUint32SliceBytes-4    \t1000000000\t         0.310 ns/op\t3226.48 MB/s\nBenchmarkMaxUint64SliceBytes-4    \t1000000000\t         0.309 ns/op\t3237.72 MB/s\nBenchmarkMaxVarintSliceBytes-4    \t1000000000\t         0.313 ns/op\t3193.07 MB/s\nBenchmarkMaxFloat32SliceBytes-4   \t1000000000\t         0.310 ns/op\t12913.98 MB/s\nBenchmarkMaxFloat64SliceBytes-4   \t1000000000\t         0.309 ns/op\t25866.04 MB/s\nBenchmarkMaxBoolSliceBytes-4      \t1000000000\t         0.312 ns/op\t3208.88 MB/s\nBenchmarkMaxStringSliceBytes-4    \t1000000000\t         3.11 ns/op\t 642.38 MB/s\nBenchmarkMaxBytesSliceBytes-4     \t1000000000\t         2.68 ns/op\t 746.79 MB/s\nPASS\nok  \tgithub.com/hslam/code\t246.123s\n```\n\n### License\nThis package is licensed under a MIT license (Copyright (c) 2019 Meng Huang)\n\n### Author\ncode was written by Meng Huang.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhslam%2Fcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhslam%2Fcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhslam%2Fcode/lists"}