{"id":23091071,"url":"https://github.com/go-pg/urlstruct","last_synced_at":"2025-08-20T18:58:37.944Z","repository":{"id":43341617,"uuid":"210574478","full_name":"go-pg/urlstruct","owner":"go-pg","description":"urlstruct decodes url.Values into structs","archived":false,"fork":false,"pushed_at":"2025-04-06T21:58:15.000Z","size":78,"stargazers_count":27,"open_issues_count":9,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T23:16:33.352Z","etag":null,"topics":["go","go-pg","golang","postgresql"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/go-pg/urlstruct","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/go-pg.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":"2019-09-24T10:22:16.000Z","updated_at":"2023-01-17T23:41:19.000Z","dependencies_parsed_at":"2023-11-29T06:30:11.108Z","dependency_job_id":"3eb3aa32-c75e-46a6-b707-a94a230d6953","html_url":"https://github.com/go-pg/urlstruct","commit_stats":{"total_commits":50,"total_committers":3,"mean_commits":"16.666666666666668","dds":0.26,"last_synced_commit":"7733f2501b02440179115b4d0df0d7386970e497"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-pg%2Furlstruct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-pg%2Furlstruct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-pg%2Furlstruct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-pg%2Furlstruct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-pg","download_url":"https://codeload.github.com/go-pg/urlstruct/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125593,"owners_count":21051771,"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":["go","go-pg","golang","postgresql"],"created_at":"2024-12-16T21:16:58.911Z","updated_at":"2025-04-09T23:16:36.493Z","avatar_url":"https://github.com/go-pg.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# urlstruct decodes url.Values into structs\n\n[![Build Status](https://travis-ci.org/go-pg/urlstruct.svg?branch=master)](https://travis-ci.org/go-pg/urlstruct)\n[![GoDoc](https://godoc.org/github.com/go-pg/urlstruct?status.svg)](https://godoc.org/github.com/go-pg/urlstruct)\n\n## Example\n\nFollowing example decodes URL query `?page=2\u0026limit=100\u0026author_id=123` into a struct.\n\n```go\ntype Book struct {\n\ttableName struct{} `pg:\"alias:b\"`\n\n\tID        int64\n\tAuthorID  int64\n\tCreatedAt time.Time\n}\n\ntype BookFilter struct {\n\ttableName struct{} `urlstruct:\"b\"`\n\n\turlstruct.Pager\n\tAuthorID int64\n}\n\nfunc ExampleUnmarshal_filter() {\n\tdb := pg.Connect(\u0026pg.Options{\n\t\tUser:     \"postgres\",\n\t\tPassword: \"\",\n\t\tDatabase: \"postgres\",\n\t})\n\tdefer db.Close()\n\n\tvalues := url.Values{\n\t\t\"author_id\": {\"123\"},\n\t\t\"page\":      {\"2\"},\n\t\t\"limit\":     {\"100\"},\n\t}\n\tfilter := new(BookFilter)\n\terr := urlstruct.Unmarshal(values, filter)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfilter.Pager.MaxLimit = 100     // default max limit is 1000\n\tfilter.Pager.MaxOffset = 100000 // default max offset is 1000000\n\n\t// Following query generates:\n\t//\n\t// SELECT \"b\".\"id\", \"b\".\"author_id\", \"b\".\"created_at\"\n\t// FROM \"books\" AS \"b\"\n\t// WHERE \"b\".author_id = 123\n\t// LIMIT 100 OFFSET 100\n\n\tvar books []*Book\n\t_ = db.Model(\u0026books).\n\t\tWhereStruct(filter).\n\t\tLimit(filter.Pager.GetLimit()).\n\t\tOffset(filter.Pager.GetOffset()).\n\t\tSelect()\n\n\tfmt.Println(\"author\", filter.AuthorID)\n\tfmt.Println(\"limit\", filter.GetLimit())\n\tfmt.Println(\"offset\", filter.GetLimit())\n\t// Output: author 123\n\t// limit 100\n\t// offset 100\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-pg%2Furlstruct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-pg%2Furlstruct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-pg%2Furlstruct/lists"}