https://stackoverflow.com/questions/37780520/unknown-field-in-struct-literal

Issue was lowercase fields

On Tuesday, May 3, 2022 at 11:19:28 AM UTC-4 Jesse Thompson wrote:

> Yikes, I feel pretty dumb. The tutorial I was watching had log.PrintF 
> typed (I know the capital F looked really weird).
>
> Although in regards to the unknown fields on my created sms blast I am a 
> little confused.
>
> I am sending an sms blast with content string and a from (User phone 
> number) from Next.js to my node.js server via socket.io (none of this 
> matters, but im saying it anyways). My goal is to send this object to my go 
> server so that go can process a twilio job with 
> https://github.com/hibiken/asynq
>
>
> On Tuesday, May 3, 2022 at 11:09:36 AM UTC-4 Jesse Thompson wrote:
>
>> sms_server.go
>>
>> ```
>> package main
>>
>> import (
>>     "context"
>>     "log"
>>     "math/rand"
>>     "github.com/google/uuid"
>>     "net"
>>
>>     pb "tycoon.systems/tycoon-services/sms"
>>     "google.golang.org/grpc"
>> )
>>
>> const (
>>     port = ":6000"
>> )
>>
>> type SmsManagementServer struct {
>>     pb.UnimplementedSmsManagementServer
>> }
>>
>>
>> func (s *SmsManagementServer) CreateNewSmsBlast(ctx context.Context, in 
>> *pb.NewMsg) (*pb.Msg, error) {
>>     log.PrintF("Received: %v, %v", in.GetContent(), in.GetFrom())
>>     jobId := uuid.New()
>>
>>     return &pb.Msg{content: in.GetContent(), from: in.getFrom(), jobId: 
>> jobId }, nil
>> }
>>
>> func main() {
>>     lis, err := net.Listen("tcp", port)
>>     if err != nil {
>>         log.Fatalf("Failed to listen: %v", err)
>>     }
>>
>>     s := grpc.NewServer()
>>     pb.RegisterSmsManagementServer(s, &SmsManagementServer{})
>>     log.Printf("Server listening at %v", lis.Addr())
>>     if err := s.Serve(lis); err != nil {
>>         log.Fatalf("Failed to server: %v", err)
>>     }
>> }
>> ```
>>
>> On line 
>> ```log.PrintF("Received: %v, %v", in.GetContent(), in.GetFrom())``` I am 
>> getting "undefined: log.PrintF go"
>>
>> and on line 
>> ```return &pb.Msg{content: in.GetContent(), from: in.getFrom(), jobId: jobId 
>> }, nil``` 
>> I am getting "unknown field 'from' in struct literal of type 
>> tycoon_services.Msg go
>> "
>>
>> My sms.proto is defined here 
>> ```
>> syntax = "proto3";
>>
>> package sms;
>>
>> option go_package = "tycoon.systems/tycoon-services;tycoon_services";
>>
>> service smsManagement {
>>     rpc CreateNewSmsBlast (NewMsg) returns (Msg) {}
>> }
>>
>> message NewMsg {
>>     string from = 1;
>>     string content = 2;
>> }
>>
>> message Msg {
>>     string from = 1;
>>     string content = 2;
>>     int32 jobId = 3;
>> }
>> ```
>>
>> The command I've ran to build the proto files is
>> ```
>> $ protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. 
>> --go-grpc_opt=paths=source_relative ./sms/sms.proto
>> ```
>>
>> I am unsure where Im going wrong. Im more familiar with Node.js as 
>> opposed to go. Why are my log methods undefined?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/da8e3af4-ec71-4c39-8e77-81bd3e7f1df9n%40googlegroups.com.

Reply via email to