An open API service indexing awesome lists of open source software.

https://github.com/blaxberry333/venomous_app_protobuf

Developing...
https://github.com/blaxberry333/venomous_app_protobuf

protocol-buffer

Last synced: 3 months ago
JSON representation

Developing...

Awesome Lists containing this project

README

        

# Venomous Apps' Protocol Buffers & Code Generator

| | Main Skills | Topic | Supported Languages |
| :------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------: | :-----------------: |
| Protobuf | | Type Code Serialization | Golang、TypeScript |

## 🚀 Local Setup


0. setup environments

- Goalng
- Python
- Node.js


1. install protobuf for using protoc command

```shell
# 1. install protobuf compiler
brew install protobuf

# 2. check version
protoc --version
```


2. install pkg protoc-gen-go for generating Golang code, then add to $PATH

```shell
# 1. install pkg
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest

# 2. add path
export PATH="$PATH:$(go env GOPATH)/bin" >> ~/.zshrc
source ~/.zshrc

# 3. check pkg's position & version
which protoc-gen-go
protoc-gen-go --version
```


3. install pkg ts-proto for generating Typescript code

```shell
% npm install ts-proto
```


4. install all pkgs

```shell
% npm install
```

## 🛠 Commands

```shell
% make gen-all # generate all
% make gen-go # only generate Golang code
% make gen-ts # only generate Typescript code
% make gen-py # only generate Python code
```

## 🤔 How to use

### TypeScript


1. install pkg inside project

```shell
cd

yarn add git+https://github.com/BlaxBerry333/venomous_app_protobuf.git
yarn add -D google-protobuf @types/google-protobuf
```


2. import type then use

```tsx
import type { MessageNode, HTMLNode } from "venomous_app_protobuf/ts/workflow";
import type { ChatBotData } from "venomous_app_protobuf/ts/chat";
import type { NoteData } from "venomous_app_protobuf/ts/notes";
```

### Golang


1. get pkg

```shell
cd

go get github.com/BlaxBerry333/venomous_app_protobuf/go/scenario@main
```


2. import pkg then use

```go
import (
"fmt"

workflow "github.com/BlaxBerry333/venomous_app_protobuf/go/workflow"
)

var MockMessageNode = &workflow.MessageNode{
Id: 11,
Title: "xxx",
Text: "yyy",
}

var MockHTMLNode = &workflow.HTMLNode{
Id: 22,
Title: "xxx",
Text: "yyy",
}

func main() {
fmt.Println(MockMessageNode.Id)
fmt.Println(MockMessageNode.Title)
fmt.Println(MockMessageNode.Text)
}
```