{"id":20566231,"url":"https://github.com/telkomdev/go-filesig","last_synced_at":"2025-04-14T15:40:38.001Z","repository":{"id":45601149,"uuid":"513861212","full_name":"telkomdev/go-filesig","owner":"telkomdev","description":"validate Files by reading each magic number from a file for Go","archived":false,"fork":false,"pushed_at":"2023-10-15T13:46:25.000Z","size":25,"stargazers_count":3,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T04:34:51.705Z","etag":null,"topics":["file-validation","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/telkomdev.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-07-14T10:44:23.000Z","updated_at":"2024-06-30T05:17:27.000Z","dependencies_parsed_at":"2024-06-19T17:07:33.963Z","dependency_job_id":"35000964-58a1-44d2-af2e-5525239adc7d","html_url":"https://github.com/telkomdev/go-filesig","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telkomdev%2Fgo-filesig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telkomdev%2Fgo-filesig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telkomdev%2Fgo-filesig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telkomdev%2Fgo-filesig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/telkomdev","download_url":"https://codeload.github.com/telkomdev/go-filesig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248907815,"owners_count":21181403,"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-validation","go","golang"],"created_at":"2024-11-16T04:40:41.047Z","updated_at":"2025-04-14T15:40:37.978Z","avatar_url":"https://github.com/telkomdev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Go File Signature Validator\n\nsmall library to validate Files by reading each magic number from a file\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/telkomdev/go-filesig.svg)](https://pkg.go.dev/github.com/telkomdev/go-filesig)\n[![filesig Go CI](https://github.com/telkomdev/go-filesig/actions/workflows/ci.yml/badge.svg)](https://github.com/telkomdev/go-filesig/actions/workflows/ci.yml)\n\n#### Install\n\n```shell\n$ go get github.com/telkomdev/go-filesig\n```\n\n#### Usage\n\nSimple\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/telkomdev/go-filesig\"\n\t\"os\"\n)\n\nfunc main() {\n\targs := os.Args\n\n\tif len(args) \u003c 2 {\n\t\tfmt.Println(\"required input file\")\n\t\tos.Exit(1)\n\t}\n\n\tinputFileArg := args[1]\n\tinFile, err := os.Open(inputFileArg)\n\n\tif err != nil {\n\t\tfmt.Println(\"error open input file \", err)\n\t\tos.Exit(1)\n\t}\n\n\tdefer func() { inFile.Close() }()\n\n\tvalid := filesig.Is3gp(inFile)\n\tfmt.Println(valid)\n```\n\nOne Of\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/telkomdev/go-filesig\"\n\t\"os\"\n)\n\nfunc main() {\n\targs := os.Args\n\n\tif len(args) \u003c 2 {\n\t\tfmt.Println(\"required input file\")\n\t\tos.Exit(1)\n\t}\n\n\tinputFileArg := args[1]\n\tinFile, err := os.Open(inputFileArg)\n\n\tif err != nil {\n\t\tfmt.Println(\"error open input file \", err)\n\t\tos.Exit(1)\n\t}\n\n\tdefer func() { inFile.Close() }()\n\n\tvalid := filesig.IsOneOf(inFile, filesig.Is3gp, filesig.IsPng, filesig.IsJpeg)\n\tfmt.Println(valid)\n\n}\n\n```\n\nHTTP Form File\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/telkomdev/go-filesig\"\n\t\"net/http\"\n)\n\nfunc uploadFile(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"File Upload Endpoint Hit\")\n\n\t// Parse our multipart form, 10 \u003c\u003c 20 specifies a maximum\n\t// upload of 10 MB files.\n\tr.ParseMultipartForm(10 \u003c\u003c 20)\n\t// FormFile returns the first file for the given key `myFile`\n\t// it also returns the FileHeader so we can get the Filename,\n\t// the Header and the size of the file\n\tfile, handler, err := r.FormFile(\"myFile\")\n\tif err != nil {\n\t\tfmt.Println(\"Error Retrieving the File\")\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tdefer file.Close()\n\tfmt.Printf(\"Uploaded File: %+v\\n\", handler.Filename)\n\tfmt.Printf(\"File Size: %+v\\n\", handler.Size)\n\tfmt.Printf(\"MIME Header: %+v\\n\", handler.Header)\n\n\t// validate file\n\tvalidPdf := filesig.IsPdf(file)\n\tif !validPdf {\n\t\tfmt.Print(\"file is not valid PDF file \\n\")\n\t}\n\n\t// return that we have successfully uploaded our file!\n\tfmt.Fprintf(w, \"Successfully Uploaded File\\n\")\n}\n\nfunc setupRoutes() {\n\thttp.HandleFunc(\"/upload\", uploadFile)\n\thttp.ListenAndServe(\":8000\", nil)\n}\n\nfunc main() {\n\tfmt.Println(\"Hello World\")\n\tsetupRoutes()\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelkomdev%2Fgo-filesig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelkomdev%2Fgo-filesig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelkomdev%2Fgo-filesig/lists"}