Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cherry-pick improvements from gogo/protobuf #8

Merged
merged 6 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Copyright (c) 2022, The Cosmos SDK Authors. All rights reserved.
julienrbrt marked this conversation as resolved.
Show resolved Hide resolved
Copyright (c) 2013, The GoGo Authors. All rights reserved.

Protocol Buffers for Go with Gadgets
Expand Down Expand Up @@ -32,4 +33,3 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ errcheck:

drone:
sudo apt-get install protobuf-compiler
(cd $(GOPATH)/src/github.com/cosmos/gogoproto && make buildserverall)
(cd ./gogoproto && make buildserverall)

testall:
go get -u github.com/golang/protobuf/proto
Expand Down
308 changes: 0 additions & 308 deletions README

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ Cosmos's fork of [gogo/protobuf](https://github.com/gogo/protobuf).
[![Build Status](https://github.com/cosmos/gogoproto/workflows/Continuous%20Integration/badge.svg)](https://github.com/cosmos/gogoproto/actions)
[![GoDoc](https://godoc.org/github.com/cosmos/gogoproto?status.svg)](http://godoc.org/github.com/cosmos/gogoproto)

---

This code generation is used to achieve:

- fast marshalling and unmarshalling
Expand All @@ -15,3 +13,5 @@ This code generation is used to achieve:
- less typing by optionally generating extra helper code
- peace of mind by optionally generating test and benchmark code
- other serialization formats

More information in the [original readme](https://github.com/gogo/protobuf/blob/master/README).
5 changes: 3 additions & 2 deletions conformance/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ test:
./test.sh $(PROTOBUF_ROOT)

regenerate:
protoc-min-version --version="3.0.0" --proto_path=$(GOPATH)/src:$(GOPATH)/src/github.com/cosmos/gogoproto/protobuf:. --gogo_out=\
protoc-min-version --version="3.0.0" --proto_path=../protobuf:. --gogo_out=\
julienrbrt marked this conversation as resolved.
Show resolved Hide resolved
Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types,\
Mgoogle/protobuf/duration.proto=github.com/cosmos/gogoproto/types,\
Mgoogle/protobuf/struct.proto=github.com/cosmos/gogoproto/types,\
Mgoogle/protobuf/timestamp.proto=github.com/cosmos/gogoproto/types,\
Mgoogle/protobuf/wrappers.proto=github.com/cosmos/gogoproto/types,\
Mgoogle/protobuf/field_mask.proto=github.com/cosmos/gogoproto/types\
:. ./internal/conformance_proto/conformance.proto
:. ./internal/conformance_proto/conformance.proto\
-I ../gogoproto -I ../protobuf
2 changes: 1 addition & 1 deletion gogoproto/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ The most complete way to see examples is to look at

github.com/cosmos/gogoproto/test/thetest.proto

Gogoprototest is a seperate project,
Gogoprototest is a separate project,
because we want to keep gogoprotobuf independent of goprotobuf,
but we still want to test it thoroughly.

Expand Down
16 changes: 10 additions & 6 deletions proto/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,17 @@ func mergeStruct(out, in reflect.Value) {
// viaPtr indicates whether the values were indirected through a pointer (implying proto2).
// prop is set if this is a struct field (it may be nil).
func mergeAny(out, in reflect.Value, viaPtr bool, prop *Properties) {
if in.Type() == protoMessageType {
if !in.IsNil() {
if out.IsNil() {
out.Set(reflect.ValueOf(Clone(in.Interface().(Message))))
} else {
Merge(out.Interface().(Message), in.Interface().(Message))
if in.Type() == protoMessageType || (in.CanAddr() && in.Addr().Type().Implements(protoMessageType)) {
if in.Kind() == reflect.Ptr {
if !in.IsNil() {
if out.IsNil() {
out.Set(reflect.ValueOf(Clone(in.Interface().(Message))))
} else {
Merge(out.Interface().(Message), in.Interface().(Message))
}
}
} else {
Merge(out.Addr().Interface().(Message), in.Addr().Interface().(Message))
}
return
}
Expand Down
Loading