- REST 實作
- GraphQL 實作
- Json-RPC 實作
- g-RPC 實作
#到專案目錄下
$ cd path_to_dir/go-api-protocols
# 下載第三方套件
$ go mod download
# 生成swagger文檔
$ swag init
# 編譯專案(輸出到當前目錄下,檔案名為main)
$ go build -o main .
# 執行應用程式
$ ./main
#網址打入(default host=>localhost:8080)
http://{host}/swagger/index.html
#網址打入(default host=>localhost:8081)
http://{host}/graphql
需要先安裝grpcui
grpcui -plaintext {host}
#refresh swagger doc
swag init
#refresh schema
go run github.com/99designs/gqlgen generate
需要先安裝proto compiler
#refresh protocol buffer
protoc --go_out=plugins=grpc:. --go_opt=paths=source_relative protos/*.proto