• go 项目中使用air自动编译项目端口被占用解决方法


    .ari.conf 文件

    # [Air](https://github.com/cosmtrek/air) TOML 格式的配置文件
    
    # 工作目录
    # 使用 . 或绝对路径,请注意 `tmp_dir` 目录必须在 `root` 目录下
    root = "."
    tmp_dir = "tmp"
    
    [build]
    # 只需要写你平常编译使用的shell命令。你也可以使用 `make`
    cmd = "powershell.exe -file dev.ps1"
    # 由`cmd`命令得到的二进制文件名
    bin = "tmp/main.exe"
    # 自定义执行程序的命令,可以添加额外的编译标识例如添加 GIN_MODE=release
    full_bin = "tmp/main.exe"
    # full_bin = "APP_ENV=dev APP_USER=air ./tmp/main"
    # 监听以下文件扩展名的文件.
    include_ext = ["go", "tpl", "tmpl", "html"]
    # 忽略这些文件扩展名或目录
    exclude_dir = ["assets", "tmp", "vendor", "frontend/node_modules"]
    # 监听以下指定目录的文件
    include_dir = []
    # 排除以下文件
    exclude_file = []
    # 如果文件更改过于频繁,则没有必要在每次更改时都触发构建。可以设置触发构建的延迟时间
    delay = 1000 # ms
    # 发生构建错误时,停止运行旧的二进制文件。
    stop_on_error = true
    # air的日志文件名,该日志文件放置在你的`tmp_dir`中
    log = "air_errors.log"
    
    [log]
    # 显示日志时间
    time = true
    
    [color]
    # 自定义每个部分显示的颜色。如果找不到颜色,使用原始的应用程序日志。
    main = "magenta"
    watcher = "cyan"
    build = "yellow"
    runner = "green"
    
    [misc]
    # 退出时删除tmp目录
    clean_on_exit = true
    

    powershell 检查端口脚本:

    Write-Host "check port is used."
    
    $process = $(NETSTAT.EXE -ano | findstr.exe "0.0.0.0:8080")
    
    if ($process.Length -ne 0) {
        $id = $process.Split(" ")[-1]
        Write-Host "kill procsss by pid $id"
        Stop-Process -Id $id
        Write-Host "kill sucessful."
    }
    
    Write-Host "building..."
    go build -o tmp/main.exe .
    
    来啊,造作啊
  • 相关阅读:
    重要常识
    ORACLE EBS中有些VIEW经常被OU屏蔽掉数据
    如何使用ftp从Metalink上下载补丁
    SO做了Booked之后,一直处理于“已延交”,发运事务处理的活动区变灰
    WIP模块常用表结构
    BOM查看多个物料下的子物料组件
    OE模块常用表结构
    如何诊断OM中的订单出现的问题
    INV模块常用表结构
    OM定义运费和特别费用类型
  • 原文地址:https://www.cnblogs.com/linga/p/15502281.html
Copyright © 2020-2023  润新知