{"id":17434607,"url":"https://github.com/martinsd3v/go-requestparser","last_synced_at":"2025-04-16T02:43:32.940Z","repository":{"id":57561377,"uuid":"326701131","full_name":"martinsd3v/go-requestparser","owner":"martinsd3v","description":"Golang package for working with arrays on http requests","archived":false,"fork":false,"pushed_at":"2021-01-14T13:29:46.000Z","size":24,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T04:24:32.569Z","etag":null,"topics":["array-to-struct","go","golang","http-request"],"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/martinsd3v.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":"2021-01-04T13:58:43.000Z","updated_at":"2022-02-09T12:53:12.000Z","dependencies_parsed_at":"2022-09-10T08:11:38.231Z","dependency_job_id":null,"html_url":"https://github.com/martinsd3v/go-requestparser","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinsd3v%2Fgo-requestparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinsd3v%2Fgo-requestparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinsd3v%2Fgo-requestparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinsd3v%2Fgo-requestparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martinsd3v","download_url":"https://codeload.github.com/martinsd3v/go-requestparser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249185789,"owners_count":21226611,"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":["array-to-struct","go","golang","http-request"],"created_at":"2024-10-17T09:07:40.268Z","updated_at":"2025-04-16T02:43:32.917Z","avatar_url":"https://github.com/martinsd3v.png","language":"Go","readme":"# go-requestparser/parser\n\nGolang package for working with arrays on http requests\n\n###### FRONT\n\n```html\n\u003cform method=\"POST\" enctype=\"multipart/form-data\"\u003e\n    \u003cinput type=\"text\" name=\"User[full_name]\" value=\"Jonh Doe\"\u003e\n    \u003cinput type=\"text\" name=\"User[Email]\" value=\"Jonh@mail.com\"\u003e\n    \u003cinput type=\"text\" name=\"User[Pass]\" value=\"123\"\u003e\n    \u003cinput type=\"text\" name=\"User[Contact][0][Phone]\" value=\"123456\"\u003e\n    \u003cinput type=\"text\" name=\"User[Contact][0][Name]\" value=\"Mom\"\u003e\n    \u003cinput type=\"text\" name=\"User[Contact][1][Phone]\" value=\"654321\"\u003e\n    \u003cinput type=\"text\" name=\"User[Contact][1][Name]\" value=\"Daddy\"\u003e\n\u003c/form\u003e\n```\n\n###### BACK-END \n```go\nimport \"github.com/martinsd3v/go-requestparser/parser\"\n\nfunc HandleRequest(rw http.ResponseWriter, request *http.Request) {\n\t//... HandleRequest\n\tvar RequestDTO struct {\n\t\tUser struct {\n\t\t\tName string `form:\"full_name\"`\n\t\t\tEmail string\n\t\t\tPass int\n\t\t\tContact []struct{\n\t\t\t\tPhone string\n\t\t\t\tName string\n\t\t\t} \n\t\t}\n\t}\n\n\tparsed := parser.Parser(request, RequestDTO)\n\t//HandleRequest ...\n}\n```\n\n#### Installation\nMake sure that Go is installed on your computer.\nType the following command in your terminal:\n```bash\ngo get github.com/martinsd3v/go-requestparser/parser\n```\n\n#### Import package in your project\nAdd following line in your `*.go` file:\n```go\nimport \"github.com/martinsd3v/go-requestparser/parser\"\n```\nIf you are unhappy to use long `parser`, you can do something like this:\n```go\nimport (\n  ps \"github.com/martinsd3v/go-requestparser/parser\"\n)\n```\n\n#### My motivations:\n\nThis package came out of a personal need, as soon as I started to develop with GoLang I found it difficult to handle arrays received via HTTP requests. Because Go takes a different approach, especially for developers used to Node.js or PHP. This does not happen with JSON requests since data in json format is easily converted to language structure. So to receive multidimensional structure in Go, you would have to work with json, which in itself is not a problem. However if you take into account that the service must be able to function independently of the way in which the data is sent (Json, Query Params, form-data, etc.) this ends up becoming a big problem. Then using this package you can easily convert the received data to a Go structure.\n\nSo, if you are looking for a way to submit forms without having to convert your data to json and have easy access to the information on your backend, this package can be useful.\n\n###### PT-BR\n\nPacote em golang para trabalhar com arrays em requisições http\n\n#### Instalação\nCertifique-se de que Go está instalado em seu computador.\nDigite o seguinte comando em seu terminal:\n\n```bash\ngo get github.com/martinsd3v/go-requestparser/parser\n```\n\n#### Importar pacote em seu projeto\nAdicione a seguinte linha em seu arquivo `*.go`:\n```go\nimport \"github.com/martinsd3v/go-requestparser/parser\"\n```\nSe você não gostar de usar o `parser`, pode fazer algo assim:\n```go\nimport (\n  ps \"github.com/martinsd3v/go-requestparser/parser\"\n)\n```\n\n#### Minhas motivações:\n\nEsse pacote surgiu de uma necessidade pessoal, assim que comecei a desenvolver com GoLang  me deparei com a dificuldade tratar arrays recebidos via requisições HTTP. Pois Go tem uma abordagem diferente, principalmente para desenvolvedores acostumados com Node.js ou PHP. Isso não acontece com requisições do tipo JSON pois dados no formato json são facilmente convertidas para estruturas da linguagem. Então para receber estrutura multidimensional em Go teria obrigatoriamente que trabalhar com json,  oque por si só não e um problema. Entretanto se levar em consideração que o serviço deve ser capas de funcionar independente da forma em que os dados são enviados ( Json, Query Params, form-data, etc. ) isso acaba se tornando um grande problema. Então utilizando esse pacote você consegue converter facilmente os dados recebidos para uma estrutura em Go.\n\nPortanto, se você está procurando uma maneira de enviar formulários sem ter que converter seus dados para json e ter fácil acesso às informações em seu back-end, este pacote pode ser util.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinsd3v%2Fgo-requestparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartinsd3v%2Fgo-requestparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinsd3v%2Fgo-requestparser/lists"}