美文网首页
go+realize实现热更新

go+realize实现热更新

作者: 谁把月亮涂黑啦 | 来源:发表于2019-10-05 18:26 被阅读0次

看看作者对它的描述:

Realize is the Golang Task Runner which enhance your workflow by automating the most common tasks and using the best performing Golang live reloading.

image.png

习惯了webpack多年,Golang Web开发环境中怎么能少了热更新功能呢,于是搜索发现一款还不错的工具,在我的windows机器上安装,过程中发现了三个坑,还好最终都解决了。好了,上教程!

安装realize

因为之前项目里面安装了 gin 作为 web 框架,所以路由都已经写好了,供后面测试的时候用。

go get github.com/oxequa/realize

安装的时候可能会提示安装某个包失败(golang.org开头),不用慌,这几个包可以去 golang 的仓库克隆下来,放到 $GOPATH/src/golang.org/x 目录下。

配置

运行 realize init 进行一步步配置,也可以一直回车,然后参考我的配置再修改下即可,schema 下的 name 和 path 请按照实际情况写。如果你的机器是 Mac,请把杀进程命令换成pkill,这一步很重要,否则重新编译时 Gin 会一直这样提示,导致热更新失败。

[GIN-debug] [ERROR] listen tcp :8080: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted
settings:
  files:
    outputs:
      status: false
      path: ""
      name: .r.outputs.log
    logs:
      status: false
      path: ""
      name: .r.logs.log
    errors:
      status: true
      path: ""
      name: .r.errors.log
  legacy:
    force: false
    interval: 100ms
server:
  status: true
  open: false
  port: 8080
  host: http://localhost
schema:
- name: gin_app
  path: E:/WorkPlace/Go/app/gin_app/
  commands:
    # clean:
    #   status: true
    # vet:
    #   status: true
    # fmt:
    #   status: true
    # test:
    #   status: true
    # generate:
    #   status: true
    install:
      status: true
    # build:
    #   status: true
    run:
      status: true
  watcher:
    extensions:
    - go
    paths:
    - /
    scripts:
    - type: before
      command: tskill gin_app
      output: true
    ignored_paths:
    - .git
    - .realize
    - vendor

修改realize包

依次执行下面命令

cd /go/src/github.com/oxequa/realize
git fetch
git checkout v2.0.2
go get github.com/oxequa/realize

再去项目目录下运行 realize start 就可以了,热更新也正常了。
此插件已不再使用!

相关文章

  • go+realize实现热更新

    看看作者对它的描述: Realize is the Golang Task Runner which enhanc...

  • Cordova 实现热更新

    文章来源 http://blog.csdn.net/zhuzhiqiang_zhu/article/detail...

  • Cordova热更新实现

    cordova-hot-code-push-plugin npm cordova-hot-code-push gi...

  • 实现iOS热更新

    参考来自:http://www.jianshu.com/p/8cec322531aeJSPatch,也许也有很多人...

  • 热更新实现方式

    SDK 动态加载替换资源和类文件可以有几种实现方式,一种是可以资源文件和代码分开进行加载与替换,例如加载图片资源文...

  • 实现Andfix热更新

    一.什么是热修复: 正常开发流程 热修复开发流程 热修复优势 Andfix的原理是,抽象类加载器classLoad...

  • uniapp实现热更新

    后端(node.js koa2)

  • UNITY3D 热更新

    何谓热更新 Unity3D热更新就是指:用户重启客户端就能实现客户端资源代码更新的需求或者功能。 为何热更新 热更...

  • 热更新预言

    热更新 参考链接 安卓热更新之Nuwa实现步骤 Android动态加载Dex机制解析 https://github...

  • uniapp热更新(springboot实现后台)

    需要完成的功能,uniapp的热更新,原始app如下,需要在页面新加一行文字,然后实现热更新 实现原理 后台提供接...

网友评论

      本文标题:go+realize实现热更新

      本文链接:https://www.haomeiwen.com/subject/cyhypctx.html