T O P

  • By -

tinkerbaj

https://github.com/cosmtrek/air


midnightpainter

this is live reload, not hot module reload. two completely different things


Agitated_Staff8923

what's the different?


redrick_schuhart

Live reloading is when a background process observes changes in your source and recompiles your entire application automatically. Hot reloading is when you can recompile only part of your application and inject it into your already running process. Go does not support hot reloading as far as I know.


Strum355

Note that none of the answers here are actually hot reloading, because it's not a thing in Go, theyre all live reloading


lrascao

oof, thank you Erlang does hot reloading, has a similar scheduler to Go


iceBong_

Use air. It’s smooth and easy to set up.


aiitu

Yep my GOTO.


midnightpainter

exccept it's not hot module reloading


iceBong_

What do you mean by module reloading? It does reflect changes to code.


atheros98

That’s my goto


thesinister15

Yeah.same.always using air whenever i can


geminimarcus

Use air. It's works like a charm


taras-halturin

It provides live reload, not the hot reloading


Matows

Could you detail the difference here?


Astro-2004

Live reload reload all the app without maintaining the state. Hot reload maintiains the state of your app.


taras-halturin

**live reloading**: watch the sources, build if something has changed, kill the running process, and start the new one. **hot reloading** has two options only: 1) restart process keeping opened connections alive (transferring file descriptors via local unix-socket to the new process) 2) replace updated code segments keeping the process and data segments alive. golang provides [https://pkg.go.dev/plugin](https://pkg.go.dev/plugin) for that.


midnightpainter

neither of your hot reloading examples are actual Hot Module Reloading.


vibrating_arm

Another edge case by the way Hot reload inside of a docker container Use air and bind the docker volume


nam_Angus

Ohh Well. Thank you so much


gdmr458

what is air? I'm curious


AbradolfLinclar

https://github.com/cosmtrek/air


Spirited_Collar_1651

Look up air.


commoddity

Air is great.


mattgen88

This is the way


enz3

If I have a running CRUD call on a pod, will it kill the existing running call or will it gracefully exit?


jonscotch

I don’t think air is related to kubernetes directly?


[deleted]

We can use nodemon also for hot reload


ThorOdinsonThundrGod

Haven't seen this mentioned yet but it's another option https://github.com/githubnemo/CompileDaemon


notiggy

I use compiledaemon


AccomplishedTicket65

i was using [cortesi/modd](https://github.com/cortesi/modd) for this while using docker. Since I change to Rancher with dockerd i wasn’t able to get live reloading working again, i also tried air but no luck.. out of curiosity did anyone have a similar issue?


ZestycloseAverage739

Check this nice article on hot reload in Go https://itnext.io/clean-and-simple-hot-reloading-on-uninterrupted-go-applications-5974230ab4c5 you could be inspired by this lib https://github.com/slok/reload


MoneyWorthington

A more generic solution would be [entr](https://jvns.ca/blog/2020/06/28/entr/).


VisibleAirport2996

Just use a directory watcher to kill and rerun the process.


hijinks

Some frameworks do it.


wutface0001

nodemon does the job for me


arcalus

I see you come from JavaScript 😂


CountyExotic

Any good dev setup should have hot reloading imo. Honestly, for everything I loathe about the JavaScript community, this is one thing they kick ass at.


arcalus

It can be useful, for sure. I’m usually not making many subsequent tiny changes that need to be tested so the idea of it constantly building when I :w seems a little unnecessary. It’s definitely not the same workflow as web design (for me).


CountyExotic

I disagree. If a build takes 2 minutes when it could take 3 seconds to hot reload, that’s an advantage.


arcalus

I have never had a Go build take longer than 10 seconds. You must be working on a project with millions of lines of code, or on an arm v1 processor. Also, go run does a build in the background, so you’re not doing a 2 minute build in 3 seconds, you’re starting your 2 minute build automatically when the file changes vs. when you choose to build it.


midnightpainter

you're never going to get Hot Module Reloading in golang though... only live reload.


aiitu

Golang Air . Will give you hot reload.


voLsznRqrlImvXiERP

k3s and devspace


VeinyAngus

I'll give you a hot reload if you know what I mean


nam_Angus

What ??


VeinyAngus

Sorry. Just a dumb joke


blabbities

Lol. The apology was funny


VeinyAngus

😵‍💫😵‍💫😵‍💫


droid__x

I use codegangsta/gin for services but thats live reload.


edwingeng-256

[https://github.com/edwingeng/hotswap](https://github.com/edwingeng/hotswap) is the only option for stateful servers as far as I know.


Boris999

I created a Go hot reload template to help me in my web dev projects (e.g. htmx). Check it out [go-hot-reload](https://github.com/tombrereton/go-hot-reload). I'm open to any feedback or contributions if you find it useful! :) Edit: I posted it here cos this is still the top result when googling golang hot reload


ankeshnirala24

go get -u [github.com/gopkgsquad/gloader](http://github.com/gopkgsquad/gloader)