gpt4 book ai didi

swift - 生成.pb.swift模型时包含单词 "Id"的Protobuf字段名称将其大写为 "ID"

转载 作者:搜寻专家 更新时间:2023-11-01 05:34:12 25 4
gpt4 key购买 nike

我正在尝试使用 swift-protobuf:

$ protoc --version
libprotoc 3.3.0
$ protoc-gen-swift --version
protoc-gen-swift 0.9.904

我有 Test.proto 文件,我需要将其转换为 Test.pb.swift:

syntax = "proto2";

message Test {
optional int64 TestId = 1 [default = 0];
}

为此,我使用:

$ protoc --swift_opt=Visibility=Public  --swift_out=./ ./Test.proto

它生成了很长的 .pb.swift 文件:

public struct Test: SwiftProtobuf.Message {
public static let protoMessageName: String = "Test"

public var testID: Int64 {
get {return _testID ?? 0}
set {_testID = newValue}
}
/// Returns true if `testID` has been explicitly set.
....

那么,为什么 TestId 转换为 testID,例如为什么Id要大写为ID?如何修复或避免这种大写行为?

最佳答案

特定答案成立于apple/swift-protobuf repo #491 Add "id" to the list of uppercase names .

据我了解,现在我需要将所有“id”或“Id”用法重命名为“ID”。

关于swift - 生成.pb.swift模型时包含单词 "Id"的Protobuf字段名称将其大写为 "ID",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45457185/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com