惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
Microsoft Azure Blog
Microsoft Azure Blog
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
小众软件
小众软件
F
Fortinet All Blogs
Microsoft Security Blog
Microsoft Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
aimingoo的专栏
aimingoo的专栏
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
宝玉的分享
宝玉的分享
有赞技术团队
有赞技术团队
J
Java Code Geeks
WordPress大学
WordPress大学
The Cloudflare Blog

流动

山西之旅 | 流动 博客焕新,记录继续 | 流动 友链 | 流动 博客加速实践 广府古城一日游 我做了一个口播短视频二创工具:VideoRemaker Windows 下 Codex Cli 更新报 Move-Item is denied 错误的解决 Caddy 转发 GOST 报 TLS internal error 问题的排查与解决 对口型视频合成方案对比:Wav2Lip、VideoReTalking 与 MuseTalk 2026 音色克隆方案对比:IndexTTS-2、CosyVoice、GPT-SoVITS、Fish Speech、VoxCPM 部署与实测 AI Agent折腾记(OpenClaw / Hermes Agent) 我的2025年 大连之行 回家收麦 六一儿童节爬长城 Golang database/sql 数据库断线自动重连机制解析 Golang默认Http Client导致的cannot assign requested address错误 清明踏春,爬山看海 购入小牛G400T电动车 北京的三月飞雪 wrenAI本地LLM模型部署 天津一日游 2024年终总结 停止使用staticfile.org服务 使用 ImageMagick 自动添加水印,保护图片版权 如何注册一个.sol域名 奥森公园半日游 昌平42公里骑行绿道打卡 十月一日爬慕田峪长城 当Hugo遇上AVIF,优化图片加载
解决 "undeclared name: any (requires version go1.18 or la...
Liudon · 2024-06-14 · via 流动
$ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
$ 
$ protoc-gen-go --version
protoc-gen-go v1.34.2
$ 
$ sh make.sh
user.pb.go:123:45: undeclared name: any (requires version go1.18 or later)
$ 

流水线编译报错,其中make.sh文件代码:

...

protoc -I=./ --proto_path=./ --go_out=./ --go_opt=paths=source_relative user.proto 

...

go build

同样的代码在本机编译就没问题,但是放到流水线里编译就报上面的错误。

登到流水线编译机器上,看了下go的版本已经是1.18.1了,按理不应该报这个错误的。

关键之前流水线编译是没问题的,怀疑是开发分支代码的问题,用master分支编译了一下,也还是报这个错误。

手动执行make.sh里的每条命令,发现是protoc编译pb文件时报的这个错误。

经过一番查找后,发现是protoc-gen-go在4月份更新了版本,引入了新特性。

protoc-gen-go’s versions

Versions in this module
v1
    v1.34.2 Jun 11, 2024
    v1.34.1 May 6, 2024
    v1.34.0 Apr 30, 2024
    v1.33.0 Mar 5, 2024
    v1.32.0 Dec 22, 2023

Protobuf Editions Overview

Protobuf Editions replace the proto2 and proto3 designations that we have used for Protocol Buffers. Instead of adding syntax = “proto2” or syntax = “proto3” at the top of proto definition files, you use an edition number, such as edition = “2024”, to specify the default behaviors your file will have. Editions enable the language to evolve incrementally over time.

Instead of the hardcoded behaviors that older versions have had, editions represent a collection of features with a default value (behavior) per feature. Features are options on a file, message, field, enum, and so on, that specify the behavior of protoc, the code generators, and protobuf runtimes. You can explicitly override a behavior at those different levels (file, message, field, …) when your needs don’t match the default behavior for the edition you’ve selected. You can also override your overrides. The section later in this topic on lexical scoping goes into more detail on that.

改用历史版本后解决。

go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.33.0