{"id":15655447,"url":"https://github.com/liamg/magic","last_synced_at":"2026-03-27T02:59:59.003Z","repository":{"id":57567517,"uuid":"167136530","full_name":"liamg/magic","owner":"liamg","description":":tophat::rabbit2: Toolkit for detecting and verifying file type using magic bytes in pure Golang","archived":false,"fork":false,"pushed_at":"2023-07-28T07:55:09.000Z","size":128,"stargazers_count":26,"open_issues_count":1,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-05T04:04:09.179Z","etag":null,"topics":["file-signature","magic-bytes","magic-numbers"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liamg.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}},"created_at":"2019-01-23T07:19:01.000Z","updated_at":"2025-04-02T11:00:20.000Z","dependencies_parsed_at":"2024-06-19T02:11:54.048Z","dependency_job_id":"d2a85df3-786a-4e96-a864-c8a068ea74ee","html_url":"https://github.com/liamg/magic","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liamg%2Fmagic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liamg%2Fmagic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liamg%2Fmagic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liamg%2Fmagic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liamg","download_url":"https://codeload.github.com/liamg/magic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252436291,"owners_count":21747470,"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":["file-signature","magic-bytes","magic-numbers"],"created_at":"2024-10-03T12:59:16.369Z","updated_at":"2026-03-27T02:59:53.923Z","avatar_url":"https://github.com/liamg.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# magic\n\nToolkit for detecting and verifying file type using magic bytes in pure Go\n\nSupport for all file signatures listed [here](https://en.wikipedia.org/wiki/List_of_file_signatures).\n\nYou only need to provide the first few hundred bytes of a given file to detect the file type, unless you want to detect `.iso` images, which require examination of the first 32774 bytes.\n\nA description and a suggested file extension are provided where relevant, and MIME types will be added in future.\n\n## Example Usage\n\n```go\npackage main\n\nimport \"github.com/liamg/magic\"\n\nfunc main() {\n\n    data := []byte{0xa1, 0xb2, 0xc3, 0xd4, 0x00, 0x00, 0x00, 0x00}\n\n    fileType, err := magic.Lookup(data)\n    if err != nil {\n        if err == magic.ErrUnknown {\n            fmt.Println(\"File type is unknown\")\n            os.Exit(1)\n        }else{\n            panic(err)\n        }\n    }\n\n    fmt.Printf(\"File extension:        %s\\n\", fileType.Extension)\n    fmt.Printf(\"File type description: %s\\n\", fileType.Description)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliamg%2Fmagic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliamg%2Fmagic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliamg%2Fmagic/lists"}