Issue in Grpc protos go & js interaction

15 views
Skip to first unread message

Ali Hassan

unread,
Aug 15, 2021, 12:27:35 PM8/15/21
to grpc.io
Dear Team, 
     I hope you're fine . I have face little issue integration of js and go . How to import js-protos in my vue application (dependencies issue) . 
$ protoc --proto_path=protos --js_out=import_style=commonjs,build:. protos/usersinfo.proto 
With this command In protos-folder existing usersinfo.pb.go update. 
var (
file_protos_usersinfo_proto_rawDescOnce sync.Once
file_protos_usersinfo_proto_rawDescData = file_protos_usersinfo_proto_rawDesc
)

func file_protos_usersinfo_proto_rawDescGZIP() []byte {
file_protos_usersinfo_proto_rawDescOnce.Do(func() {
file_protos_usersinfo_proto_rawDescData = protoimpl.X.CompressGZIP(file_protos_usersinfo_proto_rawDescData)
})
return file_protos_usersinfo_proto_rawDescData
}

var file_protos_usersinfo_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_protos_usersinfo_proto_goTypes = []interface{}{
(*Person)(nil), // 0: protos.Person
(*Error)(nil), // 1: protos.Error
(*Response)(nil), // 2: protos.Response
}
var file_protos_usersinfo_proto_depIdxs = []int32{
0, // 0: protos.Response.Friends:type_name -> protos.Person
1, // 1: protos.Response.errors:type_name -> protos.Error
0, // 2: protos.ProxyCommunicationService.Add:input_type -> protos.Person
0, // 3: protos.ProxyCommunicationService.Display:input_type -> protos.Person
2, // 4: protos.ProxyCommunicationService.Add:output_type -> protos.Response
2, // 5: protos.ProxyCommunicationService.Display:output_type -> protos.Response
4, // [4:6] is the sub-list for method output_type
2, // [2:4] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}

func init() { file_protos_usersinfo_proto_init() }
func file_protos_usersinfo_proto_init() {
if File_protos_usersinfo_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_protos_usersinfo_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Person); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_protos_usersinfo_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Error); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_protos_usersinfo_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Response); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_protos_usersinfo_proto_rawDesc,
NumEnums: 0,
NumMessages: 3,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_protos_usersinfo_proto_goTypes,
DependencyIndexes: file_protos_usersinfo_proto_depIdxs,
MessageInfos: file_protos_usersinfo_proto_msgTypes,
}.Build()
File_protos_usersinfo_proto = out.File
file_protos_usersinfo_proto_rawDesc = nil
file_protos_usersinfo_proto_goTypes = nil
file_protos_usersinfo_proto_depIdxs = nil
}
After this code can still use in vue application. If yes then how? And usersinfo.pb.js created inside build folder
. Please resolve this error. Have a nice day

Reply all
Reply to author
Forward
0 new messages