{"id":13490552,"url":"https://github.com/DmitriyVTitov/size","last_synced_at":"2025-03-28T06:31:35.435Z","repository":{"id":42173252,"uuid":"274420492","full_name":"DmitriyVTitov/size","owner":"DmitriyVTitov","description":"The size of variable at runtime","archived":false,"fork":false,"pushed_at":"2022-10-09T09:33:01.000Z","size":39,"stargazers_count":102,"open_issues_count":4,"forks_count":19,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-02-13T13:38:17.172Z","etag":null,"topics":[],"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/DmitriyVTitov.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-06-23T14:00:13.000Z","updated_at":"2024-02-09T06:28:29.000Z","dependencies_parsed_at":"2023-01-19T16:45:30.415Z","dependency_job_id":null,"html_url":"https://github.com/DmitriyVTitov/size","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DmitriyVTitov%2Fsize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DmitriyVTitov%2Fsize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DmitriyVTitov%2Fsize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DmitriyVTitov%2Fsize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DmitriyVTitov","download_url":"https://codeload.github.com/DmitriyVTitov/size/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245984569,"owners_count":20704792,"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":[],"created_at":"2024-07-31T19:00:48.429Z","updated_at":"2025-03-28T06:31:34.095Z","avatar_url":"https://github.com/DmitriyVTitov.png","language":"Go","readme":"# size - calculates variable's memory consumption at runtime\n\n### Part of the [Transflow Project](http://transflow.ru/)\n\nSometimes you may need a tool to measure the size of object in your Go program at runtime. This package makes an attempt to do so. Package based on `binary.Size()` from Go standard library.\n\nFeatures:\n- supports non-fixed size variables and struct fields: `struct`, `int`, `slice`, `string`, `map`;\n- supports complex types including structs with non-fixed size fields;\n- supports all basic types (numbers, bool);\n- supports `chan` and `interface`;\n- supports pointers;\n- implements infinite recursion detection (i.e. pointer inside struct field references to parent struct).\n\n### Usage example\n\n```\npackage main\n\nimport (\n\t\"fmt\"\n\n\t// Use latest tag.\n\t\"github.com/DmitriyVTitov/size\"\n)\n\nfunc main() {\n\ta := struct {\n\t\ta int\n\t\tb string\n\t\tc bool\n\t\td int32\n\t\te []byte\n\t\tf [3]int64\n\t}{\n\t\ta: 10,                    // 8 bytes\n\t\tb: \"Text\",                // 16 (string itself) + 4 = 20 bytes\n\t\tc: true,                  // 1 byte\n\t\td: 25,                    // 4 bytes\n\t\te: []byte{'c', 'd', 'e'}, // 24 (slice itself) + 3 = 27 bytes\n\t\tf: [3]int64{1, 2, 3},     // 3 * 8 = 24 bytes\n\t} // 84 + 3 (padding) = 87 bytes\n\n\tfmt.Println(size.Of(a))\n}\n\n// Output: 87\n```\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDmitriyVTitov%2Fsize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDmitriyVTitov%2Fsize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDmitriyVTitov%2Fsize/lists"}