functions-framework-go icon indicating copy to clipboard operation
functions-framework-go copied to clipboard

Support for hot reload in dev environment

Open kashif-ghafoor opened this issue 1 year ago • 1 comments

The recommended method to start functions framework locally is to have cmd/main.go. I start the server using go run cmd/main.go. Each time I make changes I have to quite the program and rerun it. I couldn't find any way in documentation on how to have hot reload on source code changes.

Reference: Python's function-framework supports --debug flag for this purpose.

kashif-ghafoor avatar Dec 02 '24 06:12 kashif-ghafoor

if someone stumbles upon before before enhancement get shipped. I ended up using air. Here is the .air.toml(at root directory) file that I used

root = "."
tmp_dir = "tmp"

[build]
cmd = "go build -o ./tmp/main ./cmd/main.go"
bin = "tmp/main"
full_bin = "tmp/main"
include_ext = ["go"]
exclude_dir = ["tmp"]
delay = 1000 # in milliseconds

[log]
time = true

[screen]
clear_on_rebuild = true

kashif-ghafoor avatar Dec 27 '24 20:12 kashif-ghafoor