Open JonathanHo16 opened 2 years ago
Fix code to make it viewable:
practiceArray := []*proto.Value{
{Inner: &proto.Value_Int{Int: int64(data.M_suspensionPosition[0])}},
{Inner: &proto.Value_Int{Int: int64(data.M_suspensionPosition[1])}},
{Inner: &proto.Value_Int{Int: int64(data.M_suspensionPosition[2])}},
{Inner: &proto.Value_Int{Int: int64(data.M_suspensionPosition[3])}},
}
var testCollection = &proto.Value_Collection{Collection: {Elements: practiceArray}}
print(testCollection)
This is the fix:
&proto.Value_Collection{Collection: {Elements: practiceArray}}
-->
&proto.Value_Collection{Collection: &proto.Collection{Elements: practiceArray}}
Full code (w/ fix):
practiceArray := []*proto.Value{
{Inner: &proto.Value_Int{Int: int64(data.M_suspensionPosition[0])}},
{Inner: &proto.Value_Int{Int: int64(data.M_suspensionPosition[1])}},
{Inner: &proto.Value_Int{Int: int64(data.M_suspensionPosition[2])}},
{Inner: &proto.Value_Int{Int: int64(data.M_suspensionPosition[3])}},
}
testCollection := &proto.Value_Collection{Collection: &proto.Collection{Elements: practiceArray}}
print(testCollection)
The protobuf type can be quite verbose and can be a bit difficult to use. This project is working toward making the Go gRPC API easier to use: https://github.com/datastax-ext/astra-go-sdk. It's still early days, but maybe give it a try!
Hi I was wondering if someone could tell me what I am doing wrong here, the compiler tells me "missing type in composite literal" however, I don't know what do to fix it. I'm still kind of new to Go, gRPC, and protocol buffers. Code Snippet Below
practiceArray := []*proto.Value{ {Inner: &proto.Value_Int{Int: int64(data.M_suspensionPosition[0])}}, {Inner: &proto.Value_Int{Int: int64(data.M_suspensionPosition[1])}}, {Inner: &proto.Value_Int{Int: int64(data.M_suspensionPosition[2])}}, {Inner: &proto.Value_Int{Int: int64(data.M_suspensionPosition[3])}}, } var testCollection = &proto.Value_Collection{Collection: {Elements: practiceArray}} print(testCollection)