{"id":23718390,"url":"https://github.com/ypankaj007/design-patterns-in-go","last_synced_at":"2026-02-10T22:30:20.715Z","repository":{"id":98249539,"uuid":"192525138","full_name":"ypankaj007/design-patterns-in-go","owner":"ypankaj007","description":"Implementation of design patterns in Golang","archived":false,"fork":false,"pushed_at":"2020-03-05T10:06:10.000Z","size":79,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-30T21:20:43.345Z","etag":null,"topics":["design-pattern","go"],"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/ypankaj007.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":"2019-06-18T11:17:48.000Z","updated_at":"2020-10-13T15:32:54.000Z","dependencies_parsed_at":"2023-05-18T23:15:17.646Z","dependency_job_id":null,"html_url":"https://github.com/ypankaj007/design-patterns-in-go","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ypankaj007%2Fdesign-patterns-in-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ypankaj007%2Fdesign-patterns-in-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ypankaj007%2Fdesign-patterns-in-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ypankaj007%2Fdesign-patterns-in-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ypankaj007","download_url":"https://codeload.github.com/ypankaj007/design-patterns-in-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239808460,"owners_count":19700442,"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":["design-pattern","go"],"created_at":"2024-12-30T21:21:18.325Z","updated_at":"2026-02-10T22:30:20.629Z","avatar_url":"https://github.com/ypankaj007.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Observer Design Pattern in GO\n\nThe observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods.\n\n# Example\n\n - In the code, I took a simple message posting example over social media (Linkedin, Facebook and Twitter).\n -  User will input the message by command line and it will observer in all social media portal.\n \n# Implementation\n\n  - import observer package in our application \n  - Create Event and Register Observer\n  - Resiter observer \n    ```sh\n    privatePortal.Attach(observer) // observer defines Observer object \n\n    ```\n\n- Remove observer \n    ```sh\n    privatePortal.Detach(observer) // observer defines Observer object\n\n    ```\n\n    - Notify to observer \n    ```sh\n    privatePortal.Notify(e) // e defines Event object\n\n    ```\n  \n```sh\npackage main\n\nimport (\n\t\"bufio\"\n\tob \"design-patterns-in-go/behavioral/observer\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tfmt.Println(\"Observer application .......\")\n\t// Initialize notifier\n\tprivatePortal := ob.Initialize()\n\tfmt.Println(\"Registering linkedin observer\")\n\tprivatePortal.Attach(\u0026ob.Linkedin{})\n\n\tfmt.Println(\"Registering facebook observer\")\n\tprivatePortal.Attach(\u0026ob.Facebook{})\n\n\tfmt.Println(\"Registering twitter observer\")\n\n\tprivatePortal.Attach(\u0026ob.Twitter{})\n\n\tscanner := bufio.NewScanner(os.Stdin)\n\n\tfor scanner.Scan() {\n\t\te := ob.Event{Message: scanner.Text()}\n\t\tprivatePortal.Notify(e)\n\t}\n\tfmt.Println(scanner.Err())\n}\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fypankaj007%2Fdesign-patterns-in-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fypankaj007%2Fdesign-patterns-in-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fypankaj007%2Fdesign-patterns-in-go/lists"}