模块封装
-
go get github.com/xyy277/gallery
-
Init初始化
├── auth
│ ├── luna
│ └── star
├── cache
├── config
├── constant
├── core
├── global
│ ├── request
│ └── response
├── log
├── oss
└── util
文件夹 | 说明 | 描述 |
---|---|---|
auth |
auth 组件 | auth 接口 |
--luna |
auth 平台组件 | auth 平台组件接口 |
--star |
auth 业务组件 | auth 业务组件接口 |
cache |
cache组件 | cache接口 |
config |
配置文件 | 组件配置 |
constant |
constant常量 | constant常量 |
core |
核心包 | 核心包 |
global |
全局对象 | 全局对象 |
--request |
入参结构体 | 接收前端发送到后端的数据。 |
--response |
出参结构体 | 返回给前端的数据结构体 |
log |
日志组件 | 日志组件接口 |
oss |
oss组件 | oss组件接口 |
util |
工具包 | 工具函数封装 |
https://github.com/protocolbuffers/protobuf/releases/
- linux 安装
测试protoc -h - windwos 安装
测试 protoc --version
https://github.com/protocolbuffers/protobuf-go
- go get -v -u github.com/golang/protobuf/proto
- go get -v -u github.com/golang/protobuf/protoc-gen-go
- cd $GOPATH/src/github.com/golang/protobuf/protoc-gen-go/
- go build
- sudo cp protoc-gen-go /bin/
https://github.com/protocolbuffers/protobuf-go/releases
-
protoc --proto_path=IMPORT_PATH --go_out=DST_DIR path/to/file.proto
-
protoc --go_out=. *.proto 将本地当前文件下所有.proto文件全部编译并将结果放在当前文件夹下
--proto_path,指定了 .proto 文件导包时的路径,可以有多个,如果忽略则默认当前目录。
--go_out, 指定了生成的go语言代码文件放入的文件夹
允许使用protoc --go_out=./ *.proto的方式一次性编译多个 .proto 文件
编译时,protobuf 编译器会把 .proto 文件编译成 .pd.go 文件