百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

reload

> 编程语言
开源

Go进程轻量级自动重载.

189 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

Go进程轻量级自动重载.

Lightweight automatic reloading of Go processes.

After initialisation with reload.Do() any changes to the binary (and only the binary) will restart the process. For example:

go
func main() {
    go func() {
        err := reload.Do(log.Printf)
        if err != nil {
            panic(err) // Only returns initialisation errors.
        }
    }()

    fmt.Println(os.Args)
    fmt.Println(os.Environ())
    ch := make(chan bool)
    <-ch
}

Now use go install or go build to restart the process.

Additional directories can be watched using reload.Dir(); this is useful for reloading templates:

go
func main() {
    go func() {
        err := reload.Do(log.Printf, reload.Dir("tpl", reloadTpl))
        if err != nil {
            panic(err)
        }
    }()
}

You can also use reload.Exec() to manually restart your process without calling reload.Do().


This is an alternative to the "restart binary after any *.go file changed"-strategy that some other projects – such as gin or go-watcher – take. The advantage of reload's approach is that you have a more control over when the process restarts, and it only watches a single directory for changes which has some performance benefits, especially when used over NFS or Docker with a large number of files.

It also means you won't start a whole bunch of builds if you update 20 files in a quick succession. On a desktop this probably isn't a huge deal, but on a laptop it'll save some battery power.

Because it's in-process you can also do things like reloading just templates instead of recompiling/restarting everything.

Caveat: the old process will continue running happily if go install has a compile error, so if you missed any compile errors due to switching the window too soon you may get confused.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Gogo

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言