{"id":39674244,"url":"https://github.com/ayush-raj8/godata","last_synced_at":"2026-01-18T09:43:35.580Z","repository":{"id":87504796,"uuid":"606669534","full_name":"ayush-raj8/godata","owner":"ayush-raj8","description":"Write data to file. Standardizes the format for easy parsing and read by other programs.","archived":false,"fork":false,"pushed_at":"2023-02-27T04:46:27.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-20T12:02:50.357Z","etag":null,"topics":["data","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ayush-raj8.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-02-26T07:28:32.000Z","updated_at":"2023-02-27T04:48:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"8b13b3c1-2186-4c2f-9f9a-a20f648c2d46","html_url":"https://github.com/ayush-raj8/godata","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ayush-raj8/godata","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayush-raj8%2Fgodata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayush-raj8%2Fgodata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayush-raj8%2Fgodata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayush-raj8%2Fgodata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ayush-raj8","download_url":"https://codeload.github.com/ayush-raj8/godata/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayush-raj8%2Fgodata/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28534174,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["data","golang"],"created_at":"2026-01-18T09:43:35.488Z","updated_at":"2026-01-18T09:43:35.559Z","avatar_url":"https://github.com/ayush-raj8.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# godata\n## GoData Package\nThe GoData package provides a function for writing data to a file in JSON format. This package is useful for saving data to disk in a standardized format, making it easy to read and parse by other programs.\n\n## Installation\nTo use this package, you can simply run the following command:\n```sh\ngo get github.com/ayush-raj8/godata\n```\n\n## Usage\nTo use the GoData package, you will need to import it in your Go program:\n```sh\nimport \"github.com/username/godata\"\n```\nYou can then use the DataToFile function to write data to a file:\n```sh\ngodata.DataToFile(\"data.json\", myData1, myData2, myData3)\n```\n\nThe function takes a file path and any number of data parameters of any type. It then opens the file at the specified path, creates it if it does not exist, and writes each data parameter to the file in JSON format.\n\nThe function handles several data types differently. Complex numbers are formatted as strings, while structs are formatted as JSON with indentation for readability. All other data types are also formatted as JSON.\n\n## Example\n```sh\npackage main\n\nimport (\n\tgd \"github.com/ayush-raj8/godata\"\n)\n\ntype Person struct {\n\tName string `json:\"name\"`\n\tAge  int    `json:\"age\"`\n}\n\nfunc main() {\n\tstr := \"Hello, world!\"\n\tnum := int16(42)\n\tpi := float64(3.14159)\n\tdata := map[string]interface{}{\n\t\t\"key1\": \"value1\",\n\t\t\"key2\": 2,\n\t\t\"key3\": true,\n\t}\n\tp := Person{Name: \"Alice\", Age: 30}\n\tlist := []int{1, 2, 3}\n\tcmplx := complex(1.0, 2.0)\n\tptr := \u0026struct{ Foo string }{Foo: \"bar\"}\n\tbo := false\n\n\tgd.DataToFile(\"abc.txt\", str, num, pi, data, list, p, ptr, cmplx, bo)\n}\n```\nabc.txt will be created, it does not exists.  It will contain:\n```sh\n\"Hello, world!\"\n42\n3.14159\n{\n  \"key1\": \"value1\",\n  \"key2\": 2,\n  \"key3\": true\n}\n[\n  1,\n  2,\n  3\n]\n{\n  \"name\": \"Alice\",\n  \"age\": 30\n}\n{\n  \"Foo\": \"bar\"\n}\n(1+2i)\nfalse\n```\n## Contributing\nIf you find any issues or have suggestions for improvements, please feel free to open an issue or pull request on the GitHub repository. We welcome any and all contributions to make this package better!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayush-raj8%2Fgodata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fayush-raj8%2Fgodata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayush-raj8%2Fgodata/lists"}