# How do I implement publish subscribe in a chat application using golang?

**URL:** <https://forum.golangbridge.org/t/how-do-i-implement-publish-subscribe-in-a-chat-application-using-golang/25906>\
**Category:** Getting Help\
**Created:** [December 28, 2021, 5:52pm UTC](https://forum.golangbridge.org/t/how-do-i-implement-publish-subscribe-in-a-chat-application-using-golang/25906 "2021-12-28T17:52:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Priyanka](https://forum.golangbridge.org/letter_avatar_proxy/v4/letter/p/919ad9/32.png) [@Priyanka](https://forum.golangbridge.org/u/Priyanka)\
**Post date:** [December 28, 2021, 5:52pm UTC](https://forum.golangbridge.org/t/how-do-i-implement-publish-subscribe-in-a-chat-application-using-golang/25906/1 "2021-12-28T17:52:05Z")

</div>

I have created a basic chat app in golang . I have server code and client code . I want to now include the publish subscribe messaging pattern in the chat app I have already created. How do I do that ? My original chat app does not use websockets . It is a very basic application. If needed , I’ll share my existing code as well.

---

<div class="post-metadata">

**Author:** ![Dean\_Davidson](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/dean_davidson/32/9685_2.png) [@Dean\_Davidson](https://forum.golangbridge.org/u/Dean_Davidson)\
**Post date:** [December 28, 2021, 8:43pm UTC](https://forum.golangbridge.org/t/how-do-i-implement-publish-subscribe-in-a-chat-application-using-golang/25906/2 "2021-12-28T20:43:41Z")

</div>

This is a very broad question. I guess I would start by switching your app over to using websockets or something similar. For an example, you could check out [this proof of concept I wrote](https://github.com/DeanPDX/go-websocket-job-runner) and I bet you could repurpose some of the code in there. I used [github.com/gorilla/websocket](https://github.com/gorilla/websocket) which has great documentation and examples. Now that I think about it, they [have a chat example](https://github.com/gorilla/websocket/tree/master/examples/chat) that might be of use to you.

---

<div class="post-metadata">

**Author:** ![system](https://forum.golangbridge.org/uploads/default/original/2X/5/5ad234f7c3dbc68b6cc72d338ce4f2973d9fd81c.png) [@system](https://forum.golangbridge.org/u/system)\
**Post date:** [March 28, 2022, 8:44pm UTC](https://forum.golangbridge.org/t/how-do-i-implement-publish-subscribe-in-a-chat-application-using-golang/25906/3 "2022-03-28T20:44:06Z")

</div>

Closed on March 28, 2022, 8:44pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
