Application 2019-04-11

Notes on Implementing Hot Reload with Realize in Go

A memo on using Realize for hot reloading in Go applications.

Read in: ja
Notes on Implementing Hot Reload with Realize in Go

Overview

Tried using github - oxequa/realize.

Preparation

go get github.com/oxequa/realize

Usage

./demo/
├── .realize.yaml
└── main.go

.realize.yaml

settings:
  legacy:
    force: false
    interval: 0s
schema:
- name: demo
  path: .
  commands:
    run:
      status: true
  watcher:
    extensions:
    - go
    paths:
    - /
    ignored_paths:
    - .git
    - .realize
    - vendor

main.go

package main

import (
  "fmt"
  "net/http"
)

func handler(w http.ResponseWriter, r *http.Request) {
  fmt.Fprint(w, "Hello World")
}

func main() {
  mux := http.NewServeMux()
  mux.HandleFunc("/", handler)

  http.ListenAndServe(":8080", mux)
}

In the demo directory, running realize start --server will start the monitoring server, enabling hot reload.

Monitoring server http://localhost:5002/#/demo You can view logs, errors, and output.

Server started by main.go http://localhost:8080

Impressions

It's easy to set up and convenient, so I think I'll use this for hot reloading.

Tags: Golang realize
Share: 𝕏 Post Facebook Hatena
✏️ View source / Discuss on GitHub
☕ Support

If you enjoy this blog, consider supporting it. Every bit helps keep it running!


Related Articles