Skip to content

Commit

Permalink
mv to open source repo
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaost committed Feb 14, 2025
1 parent c9a2f39 commit 0fd217b
Show file tree
Hide file tree
Showing 176 changed files with 47,377 additions and 14 deletions.
File renamed without changes.
53 changes: 52 additions & 1 deletion README.md
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).
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/cloudwego/prutal

go 1.18
Empty file added go.sum
Empty file.
54 changes: 54 additions & 0 deletions internal/desc/const.go
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
}
Loading

0 comments on commit 0fd217b

Please sign in to comment.