当前位置:网站首页>How to use go code to compile Pb generated by proto file with protoc Compiler Go file
How to use go code to compile Pb generated by proto file with protoc Compiler Go file
2022-04-23 19:21:00 【Handsome that handsome】
package main
import (
"fmt"
"ProtocDemo/example"
"github.com/golang/protobuf/proto"
"os"
)
func main() {
fmt.Println("Hello World. \n")
msg_test := &example.Person{
Name: proto.String("Davie"),
Age: proto.Int(18),
From: proto.String("China"),
}
// serialize
msgDataEncoding, err := proto.Marshal(msg_test)
if err != nil {
panic(err.Error())
return
}
msgEntity := example.Person{
}
err = proto.Unmarshal(msgDataEncoding, &msgEntity)
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
return
}
fmt.Printf(" full name :%s\n\n", msgEntity.GetName())
fmt.Printf(" Age :%d\n\n", msgEntity.GetAge())
fmt.Printf(" nationality :%s\n\n", msgEntity.GetFrom())
}
版权声明
本文为[Handsome that handsome]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210557450913.html
边栏推荐
- Using Visual Studio code to develop Arduino
- Client interns of a large factory share their experience face to face
- MySQL syntax collation (5) -- functions, stored procedures and triggers
- 数据分析学习目录
- Thoughts on the optimization of examination papers in the examination system
- OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
- MySQL syntax collation (3)
- ArcGIS JS API dojoconfig configuration
- [report] Microsoft: application of deep learning methods in speech enhancement
- Easy mock local deployment (you need to experience three times in a crowded time. Li Zao will do the same as me. Love is like a festival mock)
猜你喜欢

Using oes texture + glsurfaceview + JNI to realize player picture processing based on OpenGL es
![[record] typeerror: this getOptions is not a function](/img/c9/0d92891b6beec3d6085bd3da516f00.png)
[record] typeerror: this getOptions is not a function

Installation, use and problem summary of binlog2sql tool

Android Development: the client obtains the latest value in the database in real time and displays it on the interface

Reflection on the performance of some OpenGL operations in the past

redis优化系列(三)解决主从配置后的常见问题

5 minutes to achieve wechat cloud applet payment function (including source code)

mysql通过binlog恢复或回滚数据
![[report] Microsoft: application of deep learning methods in speech enhancement](/img/29/2d2addd826359fdb0920e06ebedd29.png)
[report] Microsoft: application of deep learning methods in speech enhancement

为何PostgreSQL即将超越SQL Server?
随机推荐
Decompile and get the source code of any wechat applet - just read this (latest)
Steps to build a deep learning environment GPU
Client interns of a large factory share their experience face to face
Openlayers draw rectangle
Some speculation about the decline of adults' language learning ability
js获取本机ip地址
[advanced level 11 of C language -- character and string functions and their simulation implementation (2)]
Parsing headless jsonarray arrays
JVM的类加载过程
5 minutes to achieve wechat cloud applet payment function (including source code)
Openlayers 5.0 discrete aggregation points
Strange problems in FrameLayout view hierarchy
Using oes texture + glsurfaceview + JNI to realize player picture processing based on OpenGL es
Redis core technology and practice 1 - start with building a simple key value database simplekv
[报告] Microsoft :Application of deep learning methods in speech enhancement
Intuitive understanding of the essence of two-dimensional rotation
SSDB foundation 2
MySQL restores or rolls back data through binlog
Sword finger offer II 116 Number of provinces - spatial complexity O (n), time complexity O (n)
開關電源設計分享及電源設計技巧圖解