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/bec521fb-3c87-4d62-966f-450d6d45d97cn%40googlegroups.com.

Reply via email to