The hotwire demo chat written in Golang

Overview

Hotwire Go Example

This is a recreation of the Hotwire Rails Demo Chat with a Go backend. See the Hotwire docs for more information about Hotwire.

Quickstart

Requirements

  • Go
  • NPM

Set up the project

Automatic

Run ./scripts/setup.sh.

Manual

  1. Download Go dependencies: go mod download
  2. Download node dependencies: npm install
  3. Create a webpack bundle: npx webpack -c webpack.config.js

Run the project

The demo can be run with go run main.go from the project root.

Packages used

Ruby On Rails provides a wealth of functionality out of the box. While batteries-included frameworks for Go web development exist (e.g. Buffalo), it's often more idiomatic to compose functionality from small, single-purpose libraries. In order to mimic some of Rails' functionality, the following packages were used:

  • Chi provides request routing and middleware support.
  • Render provides template rendering.
  • GORM provides database ORM functionality.
  • Websocket provides websocket connectivity.

In addition, the pkg directory contains a few purpose-built packages that mimic Rails functionality for the demo:

  • pubsub implements in-memory PubSub functionality that fills the role of Rails' ActionCable.
  • notify implements a cookie-based notification banner.
  • timefmt implements a helper function for formatting Go's time.Time type into a similar format to the Rails example.

Notable differences from the Rails demo

  • The Rails demo uses a Stimulus controller to do form resetting when submitting a new chat message. While Stimulus is a great framework, in Go it's generally idiomatic to reimplement small pieces of functionality instead of adding a new dependency, and because the reset controller functionality is easily implemented in pure Javascript, it felt more idiomatic to leave Stimulus out in this case.
  • Turbo Rails, and the Rails example by extension, relies heavily on ActionCable to connect Turbo Streams to a websocket. Because there is no ActionCable equivalent in Go, this example uses an in-memory pubsub mechanism and a TurboStreamWebsocketSource custom element to mimic the same functionality. In a production setting, you would probably want to use a more robust PubSub mechanism.
You might also like...
A TCP socket based chat server implemented using Go

Go Chat Server A better TCP socket chat server implemented using Go Connecting nc localhost 5000 Docker Build the container image docker build -t grub

NearTalk is chat platform to talk to people nearby.

NearTalk Visit neartalk.makeworld.space to check it out! That server always runs the latest code on the main branch. What is it? NearTalk is chat plat

 TCP based Client/Server chat CLI in Go
TCP based Client/Server chat CLI in Go

TCP based Client/Server chat CLI in Go Written in Go, this is a simple implementation of a TCP server that can detect new clients connecting and disco

Simple endpoint to create chat for specific application.

About Chat System Simple endpoint to create chat for specific application. Note This endpoints depend on chat-system repoistory, so you ought to run c

Bridge between mattermost, IRC, gitter, xmpp, slack, discord, telegram, rocketchat, twitch, ssh-chat, zulip, whatsapp, keybase, matrix, microsoft teams, nextcloud, mumble, vk and more with REST API
Bridge between mattermost, IRC, gitter, xmpp, slack, discord, telegram, rocketchat, twitch, ssh-chat, zulip, whatsapp, keybase, matrix, microsoft teams, nextcloud, mumble, vk and more with REST API

bridge between mattermost, IRC, gitter, xmpp, slack, discord, telegram, rocketchat, twitch, ssh-chat, zulip, whatsapp, keybase, matrix, microsoft teams, nextcloud, mumble, vk and more with REST API (mattermost not required!)

Matterbridge link for Minecraft Server chat.

Matterbridge link for Minecraft Server chat. Simple bridge between Minecraft, Mattermost, IRC, XMPP, Gitter, Slack, Discord, Telegram, Rocket.Chat, Hipchat(via xmpp), Matrix and Steam.

Matterbridge API plugin for Reddit Community Chat

Mattereddit 2 Mattereddit is a Matterbridge API plugin allowing you to connect Reddit group chats to the various chat services supported by Matterbrid

This app brings the Matterbridge binary to your server to connect Nextcloud Talk with other chat services

This app brings the Matterbridge binary to your server to connect Nextcloud Talk with other chat services

Chat over SSH.

ssh-chat Custom SSH server written in Go. Instead of a shell, you get a chat prompt. Demo Join the party: $ ssh ssh.chat Please abide by our project'

Owner
John Turner
John Turner
Go-random-chat - Fast and scalable real-time random chat written in go

Go Random Chat Fast and scalable real-time random chat written in go. Features:

Hao-Ming, Hsu 10 Nov 20, 2022
Tcp chat go - Create tcp chat in golang

TCP chat in GO libs Go net package and goroutines and channels tcp tcp or transm

amirbahador 0 Feb 5, 2022
A gRPC and WS voice chat server written in Go.

VoGRPC Voice over gRPC A small WS and gRPC server, designed to support voice messaging. Progress so far: WS + Socket.io support Roadmap Database desig

Yoan Sredkov 0 Nov 4, 2021
Um chat feito em go utilizando gorilla/websocket, go-redis/redis,golang-jwt/jwte labstack/echo.

go-chat Um chat feito em go utilizando gorilla/websocket, go-redis/redis,golang-jwt/jwte labstack/echo. Why Eu gostaria de aprender algumas ferramenta

Kevin Souza 0 Jul 14, 2022
The devs are over here at devzat, chat over SSH!

Devzat Where are the devs at? Devzat! Devzat is chat over SSH Try it out: ssh sshchat.hackclub.com Add this to ~/.ssh/config: Host chat HostName s

Ishan Goel 1.4k Dec 1, 2022
Instant, disposable, single-binary web based live chat server. Go + VueJS.

Niltalk Niltalk is a web based disposable chat server. It allows users to create password protected disposable, ephemeral chatrooms and invite peers t

Kailash Nadh 855 Nov 17, 2022
Decentralized Chat ( 去中心化的聊天系统 )

dchat Introduce dchat (Decentralized Chat) 一款去中心化的聊天系统。 Features 轻量级 Unix指令交互 去中心化 断线重连 支持集群 分布式ID Start Install go get -u github.com/awesome-cmd/dcha

null 14 Jul 2, 2022
Cross-platform, multi-server chat app built using Fyne

Fibro Really early days proof of concept for a cross-platform multi-server chat. Feel free to play, but don't expect it to do much! Features Multiple

Andy Williams 23 Sep 10, 2022
A framework for building chat interfaces with gioui.org.

chat A framework for building chat interfaces with gioui.org. The canonical copy of this repository is hosted on Sourcehut. We also have: An issue tra

null 9 Dec 1, 2022
gopunch is a go implementation of a peer-to-peer chat service built using UDP hole punching.

Gopunch gopunch is a go implementation of a peer-to-peer chat service built using UDP hole punching. This is a toy implementation that I put together

Peyton Walters 10 May 24, 2022