You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Windows系统编译Prometheus UI静态二进制文件?

编译Prometheus UI Windows二进制文件的依赖问题解决办法

问题背景

需要在Windows上编译Prometheus UI静态二进制文件,作为Grafana访问GCP托管Prometheus指标的认证代理。使用Go v1.19.3/v1.18.8运行go run main.go时出现依赖缺失提示,执行go get github.com/GoogleCloudPlatform/prometheus-engine/pkg/ui时返回错误:

go: github.com/GoogleCloudPlatform/prometheus-engine/pkg/ui: no matching versions for query "upgrade"

解决步骤

  • 自动同步依赖:在项目源码目录执行go mod tidy,该命令会自动识别源码中的import语句,拉取匹配的依赖版本,无需手动指定包路径。
  • 配置Go代理:Windows环境下若无法拉取依赖,执行go env -w GOPROXY=https://proxy.golang.org,direct开启官方代理,之后重新运行go mod tidy。
  • 手动替换依赖:如果自动同步失败,先克隆仓库到本地GOPATH对应目录:
    git clone https://github.com/GoogleCloudPlatform/prometheus-engine.git %GOPATH%\src\github.com\GoogleCloudPlatform\prometheus-engine
    
    再在项目目录执行:
    go mod edit -replace github.com/GoogleCloudPlatform/prometheus-engine/pkg/ui=%GOPATH%\src\github.com\GoogleCloudPlatform\prometheus-engine\pkg\ui
    go mod tidy
    
  • 拉取分支最新代码:若仓库无正式发布版本,直接指定master分支拉取:
    go get github.com/GoogleCloudPlatform/prometheus-engine/pkg/ui@master
    

内容的提问来源于stack exchange,提问作者DevOpsNewbie

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 03:55:28