{"id":15394221,"url":"https://github.com/xyproto/binary","last_synced_at":"2025-04-15T23:52:42.113Z","repository":{"id":57662981,"uuid":"479327077","full_name":"xyproto/binary","owner":"xyproto","description":":paw_prints: Detect if a file is binary or text","archived":false,"fork":false,"pushed_at":"2024-01-25T14:31:50.000Z","size":1143,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T03:02:11.365Z","etag":null,"topics":["binary","go","module","text","utility"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xyproto.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":"2022-04-08T09:27:29.000Z","updated_at":"2024-09-11T16:40:26.000Z","dependencies_parsed_at":"2024-06-21T18:56:00.981Z","dependency_job_id":"21a6f54b-5346-49f6-a61a-43dced8022f1","html_url":"https://github.com/xyproto/binary","commit_stats":null,"previous_names":["xyproto/bin"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyproto%2Fbinary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyproto%2Fbinary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyproto%2Fbinary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyproto%2Fbinary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xyproto","download_url":"https://codeload.github.com/xyproto/binary/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249173061,"owners_count":21224481,"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":["binary","go","module","text","utility"],"created_at":"2024-10-01T15:22:29.015Z","updated_at":"2025-04-15T23:52:42.094Z","avatar_url":"https://github.com/xyproto.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Binary\n\nGo module and command line utility for checking if the given file or data is likely to be **binary** or **text**.\n\n* It does so by reading the first, middle and last 24 bytes of the file and trying to convert the data to utf8.\n* If one of the 24 byte blocks can not be converted to utf8, it's considered to be a binary file.\n* Also, if one of the blocks have more than 33% zero bytes, it's considered to be a binary file.\n* If the file is empty, it's considered to be a text file.\n* The `binary` utility has overlapping functionality with the `file` utility, but with a more limited focus.\n* If the first 24 bytes indicates that it's a binary file, the deduction is done, and no more seeking or reading will happen.\n\n## Installing the utility\n\nWith Go 1.17 or later:\n\n    go install github.com/xyproto/binary/cmd/binary@latest\n\n## Example use\n\n* `binary /usr/bin/ls` returns `binary`.\n* `binary /etc/fstab` returns `text`.\n\n## Using the Go module\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"os\"\n\n    \"github.com/xyproto/binary\"\n)\n\nfunc main() {\n    filename := os.Args[0]\n    isBinary, err := binary.File(filename)\n    if err != nil {\n        fmt.Fprintf(os.Stderr, \"%s\\n\", err)\n        os.Exit(1)\n    }\n    fmt.Printf(\"%s is a binary file: %v\\n\", filename, isBinary)\n}\n```\n\nThe `binary.Data` function can be used to determine if a byte slice contains binary data or not.\n\n## General info\n\n* Version: 1.3.3\n* License: BSD-3\n* Author: Alexander F. Rødseth \u0026lt;xyproto@archlinux.org\u0026gt;\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxyproto%2Fbinary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxyproto%2Fbinary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxyproto%2Fbinary/lists"}