Not a Go LiveView developer yet? Try to guess what this code is doing, though.
Tags: go, webdev, fiber, gin
Published: 2023-02-15 07:30:00

---
title: Not a Go LiveView developer yet? Try to guess what this code is doing, though.
published: true
description: Not a Go LiveView developer yet? Try to guess what this code
tags: go,webdev,fiber,gin
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
published_at: 2023-02-15 07:30 +0000
---
My common practice for evaluating new technology, framework, or programming approach is based on the first feeling I have from the code presented. What is the cognitive effort to understand “the idea”? Things have to “look nice and be polished” in some way to convince me. I can still remember that overall ‘wow effect’ when seeing my first [Phoenix LiveView](https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html) presentation a few years ago. Such a small amount of code and a great level of expressiveness so even not being a daily [Elixir](https://elixir-lang.org/) developer make me an idea, of how this is supposed to work and what the code is doing.

> [LiveView implementation](https://github.com/jfyne/live) for Go raised the same type of feelings in me when I went through this for the first time.

Just make a quick review of the code below without seeing any other details:
![Example](https://miro.medium.com/max/720/1*Jt3gghYFiRJaL75ZZTw0BA.webp)

That is like we write stuff in Go LiveView implementation.

**ad 1)** In HTML we use tag attributes to specify LiveView-related actions. LiveView makes those things actually ‘live and working’, no other JS code is needed. We have defined LiveView click event here. In other words, we just said: “send ‘temp-up’ event back to backed, when this button is clicked in the browser”. LiveView detects this attribute in HTML and provides the appropriate actions that will make a backend call through the websocket. LiveView establishes a websocket connection to our backend when a web page is loaded in a browser for the first time.

**ad 2)** We reference variables from our backend model using Go Template syntax. LiveView keeps those values updated whenever the backend representation is changed. LiveView uses websocket push technology under the scene here.

**ad 3)** We tight ‘temp-up’ event front end is emitting to our backend handler. LiveView calls our handler whenever a ‘temp-up’ event is emitted. We can just rely on that.

**To learn more, you can take a look at my previous articles on LiveView here:**

* [Mastering LiveView development in GoLang](https://dev.to/dmarko484/mastering-liveview-development-in-golang-169f)
* [3 issues LiveView development in Go resolve efficiently for small teams](https://dev.to/dmarko484/3-issues-liveview-development-in-go-resolve-efficiently-for-small-teams-2bn)

Are you still with me? Nice. If you are interested in details and want to get a whole idea of how you can use the LiveView programming approach in Go for your new or existing projects, you are welcome to take part in this new Udemy Course “[Mastering Live(View) development in Go](https://www.udemy.com/course/mastering-liveview-development-in-go-golang/?referralCode=17A93DEEFD7A2D0930CC)”.

![Udemy course](https://miro.medium.com/proxy/0*oqTBwdgXQeG_j7h2.webp)