{"id":19666643,"url":"https://github.com/xaionaro-go/gosrc","last_synced_at":"2026-06-13T00:31:16.776Z","repository":{"id":71636426,"uuid":"313698484","full_name":"xaionaro-go/gosrc","owner":"xaionaro-go","description":"Parse Go packages to handy structures (to save time on understanding `go/ast` and `go/types`).","archived":false,"fork":false,"pushed_at":"2020-11-24T18:14:23.000Z","size":28,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-27T04:17:29.736Z","etag":null,"topics":["ast","go","golang","parser"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xaionaro-go.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":"2020-11-17T17:48:58.000Z","updated_at":"2020-11-24T18:14:26.000Z","dependencies_parsed_at":"2023-04-18T15:18:32.533Z","dependency_job_id":null,"html_url":"https://github.com/xaionaro-go/gosrc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xaionaro-go/gosrc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xaionaro-go%2Fgosrc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xaionaro-go%2Fgosrc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xaionaro-go%2Fgosrc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xaionaro-go%2Fgosrc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xaionaro-go","download_url":"https://codeload.github.com/xaionaro-go/gosrc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xaionaro-go%2Fgosrc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34268187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"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":["ast","go","golang","parser"],"created_at":"2024-11-11T16:28:24.837Z","updated_at":"2026-06-13T00:31:16.757Z","avatar_url":"https://github.com/xaionaro-go.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GoDoc](https://godoc.org/github.com/xaionaro-go/gosrc?status.svg)](https://pkg.go.dev/github.com/xaionaro-go/gosrc?tab=doc)\n[![go report](https://goreportcard.com/badge/github.com/xaionaro-go/gosrc)](https://goreportcard.com/report/github.com/xaionaro-go/gosrc)\n\u003cp xmlns:dct=\"http://purl.org/dc/terms/\" xmlns:vcard=\"http://www.w3.org/2001/vcard-rdf/3.0#\"\u003e\n  \u003ca rel=\"license\"\n     href=\"http://creativecommons.org/publicdomain/zero/1.0/\"\u003e\n    \u003cimg src=\"http://i.creativecommons.org/p/zero/1.0/88x31.png\" style=\"border-style: none;\" alt=\"CC0\" /\u003e\n  \u003c/a\u003e\n  \u003cbr /\u003e\n  To the extent possible under law,\n  \u003ca rel=\"dct:publisher\"\n     href=\"https://github.com/xaionaro-go/rpn\"\u003e\n    \u003cspan property=\"dct:title\"\u003eDmitrii Okunev\u003c/span\u003e\u003c/a\u003e\n  has waived all copyright and related or neighboring rights to\n  \u003cspan property=\"dct:title\"\u003egosrc\u003c/span\u003e.\nThis work is published from:\n\u003cspan property=\"vcard:Country\" datatype=\"dct:ISO3166\"\n      content=\"IE\" about=\"https://github.com/xaionaro-go/gosrc\"\u003e\n  Ireland\u003c/span\u003e.\n\u003c/p\u003e\n\n\n# About\n\nThis package just simplifies working with `go/*` packages to parse a source code.\nInitially the package was written to simplify code generation.\n\n# Quick start\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"go/build\"\n\n    \"github.com/xaionaro-go/gosrc\"\n)\n\nfunc assertNoError(err error) {\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc main() {\n\tdir, err := gosrc.OpenDirectoryByPkgPath(\u0026build.Default, \"github.com/xaionaro-go/gosrc\", false, false, false, nil)\n\tassertNoError(err)\n\n\tif len(dir.Packages) != 1 {\n\t\tpanic(\"expected one package\")\n\t}\n\tpkg := dir.Packages[0]\n\n\tfor _, file := range pkg.Files {\n\t\tfor _, s := range file.Structs() {\n\t\t\tfields, err := s.Fields()\n\t\t\tassertNoError(err)\n\t\t\tfmt.Println(\"amount of fields:\", len(fields), \";\\t amount of methods:\", len(s.Methods()), \";  \\tstruct name:\", s.Name())\n\t\t}\n\t}\n}\n```\nThe output is:\n```\namount of fields: 2 ;    amount of methods: 0 ;         struct name: Directory\namount of fields: 2 ;    amount of methods: 1 ;         struct name: ErrPackageNotFound\namount of fields: 5 ;    amount of methods: 7 ;         struct name: Field\namount of fields: 2 ;    amount of methods: 0 ;         struct name: TypeNameValue\namount of fields: 3 ;    amount of methods: 12 ;        struct name: File\namount of fields: 1 ;    amount of methods: 0 ;         struct name: Func\namount of fields: 6 ;    amount of methods: 5 ;         struct name: Package\namount of fields: 3 ;    amount of methods: 5 ;         struct name: Struct\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxaionaro-go%2Fgosrc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxaionaro-go%2Fgosrc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxaionaro-go%2Fgosrc/lists"}