{"id":18293232,"url":"https://github.com/maki-daisuke/go-kaito","last_synced_at":"2025-04-09T08:15:20.802Z","repository":{"id":57512490,"uuid":"45571922","full_name":"Maki-Daisuke/go-kaito","owner":"Maki-Daisuke","description":"Auto-detect and decompress Gzip/Bzip2/Xz-compressed data","archived":false,"fork":false,"pushed_at":"2020-02-15T06:23:57.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T00:52:10.022Z","etag":null,"topics":["auto-detection","bzip2","decompression","golang","gzip","xz"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Maki-Daisuke.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":"2015-11-04T22:33:40.000Z","updated_at":"2019-10-11T22:11:10.000Z","dependencies_parsed_at":"2022-09-26T17:51:41.823Z","dependency_job_id":null,"html_url":"https://github.com/Maki-Daisuke/go-kaito","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/Maki-Daisuke%2Fgo-kaito","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maki-Daisuke%2Fgo-kaito/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maki-Daisuke%2Fgo-kaito/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maki-Daisuke%2Fgo-kaito/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Maki-Daisuke","download_url":"https://codeload.github.com/Maki-Daisuke/go-kaito/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247999864,"owners_count":21031046,"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":["auto-detection","bzip2","decompression","golang","gzip","xz"],"created_at":"2024-11-05T14:23:20.577Z","updated_at":"2025-04-09T08:15:20.728Z","avatar_url":"https://github.com/Maki-Daisuke.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Kaito\n=====\n\nKaito (káitəʊ) is auto-detection and decompression tool for Go.\n\n\nMotivation\n----------\n\nThese days, I've been working on log files with several formats; some are Gzipped,\nothers are Xz-compressed, and even others are just plain text. OMG! I don't mind\nwhatever compression format is used, but just want plain content.\n\n\nUsage\n-----\n\nJust make `kaito.Reader` from another `io.Reader`, then read from it.\n\nExample:\n\n```go\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\n\t\"github.com/Maki-Daisuke/go-kaito\"\n)\n\nfunc main() {\n\tfor _, f := range os.Args[1:] {\n\t\tfile, err := os.Open(f)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tk := kaito.New(file)\n\t\tr := bufio.NewReader(k)\n\t\tfor {\n\t\t\tline, err := r.ReadString('\\n')\n\t\t\tif err != nil {\n\t\t\t\tif err == io.EOF {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\tfmt.Print(line) // `Here, line is decompressed string if the file is compressed, as-is otherwise.\n\t\t}\n\t}\n}\n```\n\nYou can make it from any kind of `io.Reader`. For example, you can easily\nimplement your own filter command with reading STDIN:\n\n```go\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\n\t\"github.com/Maki-Daisuke/go-kaito\"\n)\n\nfunc main() {\n\tk := kaito.New(os.Stdin)\n\tr := bufio.NewReader(k)\n\tfor {\n\t\tline, err := r.ReadString('\\n')\n\t\tif err != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tpanic(err)\n\t\t}\n\t\t// Do what you want to do.\n\t}\n}\n```\n\n\nPrerequisites\n---------------\n\nIt is recommended to install `gzip`, `bzip2` and `xz` commands. \nKaito tries to use these commands, and fallbacks to Go-native implementation of \nthose algorithms if the commands fail. \nThus, those commands are not mandatory, but they are much faster than Go-native \nimplementations according to my experience.\n\n\nLicense\n-------\n\nThe Simplified BSD License (2-clause)\n\n\nAuthor\n---------\n\nDaisuke (yet another) Maki\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaki-daisuke%2Fgo-kaito","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaki-daisuke%2Fgo-kaito","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaki-daisuke%2Fgo-kaito/lists"}