{"id":26022123,"url":"https://github.com/MarcGrol/golangAnnotations","last_synced_at":"2025-03-06T09:54:36.536Z","repository":{"id":44288725,"uuid":"60021737","full_name":"MarcGrol/golangAnnotations","owner":"MarcGrol","description":"Go package that provides annotations for golang to speedup web development","archived":false,"fork":false,"pushed_at":"2022-11-25T11:55:42.000Z","size":3287,"stargazers_count":345,"open_issues_count":2,"forks_count":40,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-08T11:52:05.578Z","etag":null,"topics":["annotations","code-generation","go","golang","golang-tools","parser","tools"],"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/MarcGrol.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":"2016-05-30T15:49:27.000Z","updated_at":"2024-10-27T06:58:13.000Z","dependencies_parsed_at":"2023-01-22T18:30:13.154Z","dependency_job_id":null,"html_url":"https://github.com/MarcGrol/golangAnnotations","commit_stats":null,"previous_names":["marcgrol/asttools"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcGrol%2FgolangAnnotations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcGrol%2FgolangAnnotations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcGrol%2FgolangAnnotations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcGrol%2FgolangAnnotations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarcGrol","download_url":"https://codeload.github.com/MarcGrol/golangAnnotations/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242187638,"owners_count":20086217,"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":["annotations","code-generation","go","golang","golang-tools","parser","tools"],"created_at":"2025-03-06T09:54:24.479Z","updated_at":"2025-03-06T09:54:36.517Z","avatar_url":"https://github.com/MarcGrol.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/MarcGrol/golangAnnotations.svg?branch=master)](https://travis-ci.com/MarcGrol/golangAnnotations)\r\n[![Coverage Status](https://coveralls.io/repos/github/MarcGrol/golangAnnotations/badge.svg)](https://coveralls.io/github/MarcGrol/golangAnnotations)\r\n[![BCH compliance](https://bettercodehub.com/edge/badge/MarcGrol/golangAnnotations?branch=master)](https://bettercodehub.com/)\r\n[![Maintainability](https://api.codeclimate.com/v1/badges/ec16a2ec356e87ccfbaf/maintainability)](https://codeclimate.com/github/MarcGrol/golangAnnotations/maintainability)\r\n\r\n[Detailed explanation](https://github.com/MarcGrol/golangAnnotations/wiki)\r\n\r\n## Summary\r\n\r\nThe golangAnnotations-tool parses your golang source-code into an intermediate representation.\r\n\r\nUsing this intermediate representation, the tool uses your annotations to generate source code that would be cumbersome and error-prone to write manually.\r\n\r\nBottom line, a lot less code needs to be written.\r\n\r\nExample:\r\n    \r\n    // @RestOperation( method = \"GET\", path = \"/person/{uid}\" )\r\n    func (s *Service) getPerson(c context.Context, uid string) (*Person, error) {\r\n        ...\r\n    } \r\n\r\nBased on the annotation line code is generated that will do do all http handling:\r\n  - read-request\r\n  - unmarshall request\r\n  - call business logic\r\n  - marshall response\r\n  - write response \r\n\r\nIn addition, typestrong test functions are generated that ease testing of your rest operations.\r\n\r\nThe same \"annotation\"-approach is used to ease event-sourcing.\r\n\r\n## Getting the software\r\n\r\n    $ go get -u -t -v github.com/MarcGrol/golangAnnotations/...\r\n\r\n## Testing and installing\r\n\r\n    $ make gen\r\n    $ make test\r\n    $ make install\r\n    \r\n    or\r\n    \r\n    $ make\r\n\r\n## Currently supported annotations\r\n\r\nThis first implementation provides the following kind of annotations:\r\n- web-services (jax-rs like):\r\n    - Generate server-side http-handling for a \"service\"\r\n    - Generate client-side http-handling for a \"service\"\r\n    - Generate helpers to ease integration testing of your services\r\n\r\n- event-listeners:\r\n    - Generate server-side http-handling for receiving events\r\n    - Generate helpers to ease integration testing of your event-listeners\r\n\r\n- event-sourcing:\r\n    - Describe which events belong to which aggregate\r\n    - Type-strong boiler-plate code to build an aggregate from individual events\r\n    - Type-strong boiler-plate code to wrap and unwrap events into an envelope so that it can be easily stored and emitted\r\n\r\n## How to use http-server related annotations (\"jax-rs\"-like)?\r\n\r\nA regular golang struct definition with our own \"RestService\" and \"RestOperation\"-annotations. Observe that [./examples/rest/tourService.go](./examples/myrest/tourService.go) is used as input.\r\n\r\n    // @RestService( path = \"/api\" )\r\n    type Service struct {\r\n       ...\r\n    }\r\n    \r\n    // @RestOperation( method = \"GET\", path = \"/person/{uid}\" )\r\n    func (s *Service) getPerson(c context.Context, uid string) (*Person, error) {\r\n        ...\r\n    }        \r\n\r\nObserve that ./examples/rest/gen_tourService.go have been generated.\r\n\r\n[Example](https://github.com/MarcGrol/golangAnnotations/wiki/example-of-generated-code) of the generated http handler.\r\n\r\n## How to use event-sourcing related annotations?\r\n\r\nA regular golang struct definition with our own \"Event\"-annotation.\r\n    \r\n    // @Event( aggregate = Tour\" )\r\n    type TourEtappeCreated struct {\r\n        ...\r\n    }        \r\n\r\nObserve that ./examples/event/gen_wrappers.go and ./examples/event/gen_aggregates.go have been created in ./examples/structExample.\r\n\r\n### Command to trigger code-generation:\r\n\r\nWe use the \"go:generate\" mechanism to trigger our goAnnotations-executable.\r\nIn order to trigger this mechanisme we use a '//go:genarate' comment with the command to be executed.\r\n\r\nexample:\r\n\r\n    //go:generate golangAnnotations -input-dir .\r\n\r\nSo can can use the regular toolchain to trigger code-genaration\r\n\r\n    $ cd ${GOPATH/src/github.com/MarcGrol/golangAnnotations\r\n    $ go generate ./...\r\n    // go imports will fix all the imports\r\n    $ for i in `find . -name \"*.go\"`; do goimports -w -local github.com/ ${i}; done\r\n    // fixes formatting for generated code\r\n    $ for i in `find . -name \"*.go\"`; do gofmt -s -w ${i}; done\r\n    \r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMarcGrol%2FgolangAnnotations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMarcGrol%2FgolangAnnotations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMarcGrol%2FgolangAnnotations/lists"}