grpc
gRPC简介生成代码例如代码结构如下:
1234567891011project├── cmd│ ├── client│ └── server├── go.mod├── go.sum├── internal│ └── protos│ └── person.proto└── pkg └── pb
将internal/protos/*.proto编译到pkg/pb下,可写个脚本:
生成后的文件结构为:
1234567891011121314project├── cmd│ ├── client│ └── server├── go.mod├── go.sum├── internal│ └── protos│ └── person.proto├── Makefile└── pkg └── protos ├── person_grpc.pb.go └── person.pb.go
服务定义和许多RPC系统一样,gRPC基于定义服务的思想,指定可以远程调用的方法及其参数和返回类型。默认情况下,g ...
protoc3
Proto 3
一些简介Protocol Buffer是一种与语言无关,与平台无关的可扩展机制,用于序列化结构化数据
Style Guide原文
Enum Behavior在GO中,enum会被编码为int32。
枚举有两种不同的风格:open和closed。除了处理未知值意外,其他行为相同。
12345678enum Enum { A = 0; B = 1;}message Msg { optional Enum enum = 1;}
open和closed的区别可以概括为一个问题当程序解析包含enum的Msg时,其值为2,会发生什么?
open enums 将解析值 2 并将其直接存储在字段中。访问器将报告该字段已设置,并将返回代表 2 的内容
closed enums 将解析值 2 并将其存储在消息的未知字段集中。访问器将报告该字段未设置,并将返回枚举的默认值。
而所有已知的GO版本都不符合要求。GO将所有枚举视为open。
Well-Known Types and Common TypesWell-Known ...
the-past-month
The Past MonthNot Very Good
Bad News:
Still finding jobs
Don’t want to go out
Irregular work and rest
Good News:
Watch more TV
Ready to write something
Machine Learning Introduction
How Models WorkWe’ll start with a model called Decision Tree. There are fancier models that give more accurate predictions. But desision trees are easy to understand, and they are the basic building block for some of the best models in data science.
For simplicity, we’ll start with the simplest possible decision tree.
12345678910 Sample Decision Tree ---------------------------------------- | Does house have more than 2 bedrooms | ------------------------------------- ...
pandas
SummaryI learn pandas in kaggle recently, I feel that this is a simplified version of some commonly used SQL.
CodeCreating, Reading and Writing12345678910111213141516171819202122232425262728293031323334import pandas as pd# create a simple DataFramepd.DataFrame({ "Yes": [50, 21], "No": [131, 2] })# create a DataFrame with string valuepd.DataFrame({ "Bob": ["I liked it.", "It was awful"], "Sue": ["Pretty good.", & ...
Write a hash table
SummaryThis is a tiny little demo of hash table. But it can already be used to understand the map in golang in some aspects.
Steps
define data structure
implement hash function
API
insert
search
delete
Code123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 ...
Front End Tutorial
StartIf I have to pick only one website in all of the internet for recommended to the learner of front end, that must be MDN. You can find everything about front end you should know over here.
Some people start their study by Vue or React. In some case, that’s not a bad idea. You can build your web quickly with many templates in github. But, you will find you don’t know why and how to fix if some bugs appear.
At my past job, I met a guy who wrote a dozen lines of CSS just to center a DIV horizon ...