generated from cloudwego/.github
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
176 changed files
with
47,377 additions
and
14 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,52 @@ | ||
# .github | ||
# Prutal | ||
|
||
Prutal is a pure Go alternative to [protocol buffers](https://protobuf.dev), it covers most of the functionality offered by Protocol Buffers. | ||
|
||
Prutal aims to minimize code generation as much as possible while ensuring serialization and maintaining good performance. | ||
|
||
**Since Prutal is NOT yet ready for production use, we are not providing usage documentation at this time, nor do we guarantee backward compatibility of the interface.** | ||
|
||
| Features | Protobuf | Prutal | | ||
| -- | -- | -- | | ||
| Supported Languages | C++, Java, Python, Go, and more | Go | | ||
| Code Generation | ✅ | ✅ | | ||
| Serialization | ✅ | ✅ without generating code | | ||
| Performance | ⭐️⭐️⭐️ | ⭐️⭐️⭐️⭐️⭐️ | | ||
| Extensibility | 😡 Plugin | 😄 Package | ||
| Compatibility | ✅ | ✅ (see Protobuf Compatibility) | ||
| gRPC | ✅ | 🚧 Coming soon | ||
| Non-Pointer Field | ❌ | ✅ (aka gogoproto.nullable) | ||
|
||
|
||
## Protobuf Compatibility | ||
|
||
* ✅ Works with code generated by the official Protocol Buffer Go | ||
* ✅ Parsing .proto file. syntax: proto2, proto3, edition 2023 | ||
* ✅ Protobuf wire format | ||
- double, float, bool, string, bytes | ||
- int32, int64, uint32, uint64, sint32, sint64 | ||
- fixed32, fixed64, sfixed64, sfixed64 | ||
- enum | ||
- repeated, map, oneof | ||
* ✅ Packed / unpack (proto2) | ||
- PACKED / EXPANDED (repeated field encoding, edition2023) | ||
* ✅ Reserved | ||
* ✅ Unknown Fields | ||
* ⚠️ JSON support: JSON struct tag only | ||
* ⚠️ Code generation: Go only | ||
* ⚠️ Protocol buffers well-known types [link](https://protobuf.dev/reference/protobuf/google.protobuf/) | ||
- Prutal is able to generate code by reusing pkg [`google.golang.org/protobuf/type`](https://pkg.go.dev/google.golang.org/protobuf/types/known) | ||
- Features of type like `Any` would be limited. | ||
* ❌ Groups (proto2) [link](https://protobuf.dev/programming-guides/proto2/#groups) | ||
* ❌ Overriding default scalar values (proto2, edition2023) [link](https://protobuf.dev/programming-guides/proto2/#explicit-default) | ||
|
||
|
||
|
||
## Contributing | ||
|
||
Contributor guide: [Contributing](CONTRIBUTING.md). | ||
|
||
## License | ||
|
||
Prutal is licensed under the terms of the Apache license 2.0. See [LICENSE](LICENSE) for more information. | ||
Dependencies used by `prutal` are listed under [licenses](licenses). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/cloudwego/prutal | ||
|
||
go 1.18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2025 CloudWeGo Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package desc | ||
|
||
import ( | ||
"strconv" | ||
) | ||
|
||
// FieldType represents types used in struct tag | ||
type TagType uint8 | ||
|
||
const ( | ||
TypeVarint TagType = iota + 1 | ||
TypeZigZag32 | ||
TypeZigZag64 | ||
TypeFixed32 | ||
TypeFixed64 | ||
TypeBytes | ||
TypeUnknown | ||
) | ||
|
||
var typeNames = []string{ | ||
TypeVarint: "varint", | ||
TypeZigZag32: "zigzag32", | ||
TypeZigZag64: "zigzag64", | ||
TypeFixed32: "fixed32", | ||
TypeFixed64: "fixed64", | ||
TypeBytes: "bytes", | ||
} | ||
|
||
func (t TagType) String() string { | ||
ret := "" | ||
if uint(t) < uint(len(typeNames)) { | ||
ret = typeNames[uint(t)] | ||
} | ||
if ret == "" { | ||
ret = "FieldType-" + strconv.Itoa(int(t)) | ||
} | ||
return ret | ||
} |
Oops, something went wrong.