garden

command module
v0.0.0-...-c7a98c3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2022 License: MIT Imports: 1 Imported by: 0

README

garden

go language backend playground

create package

go mod init github.com/stkali/garden

cobra & cobra-cli

install

go get -u github.com/spf13/cobra@latest
go get -u github.com/spf13/cobra-cli@latest

create app structure use cobra and cobra-cli

cobra-cli init -a "<st·kali clarkmonkey@163.com>" -l MIT --viper
cobra-cli add config -a "<st·kali clarkmonkey@163.com>" -l MIT
cobra-cli add server -a "<st·kali clarkmonkey@163.com>" -l MIT

migrate

import golang migration

🏠 golang/migrate

👉 download list

migrate create -ext sql -dir db/migrations -seq desc_table

sqlc

🏠 kyleconroy/sqlc

👉 download list

sqlc generate

📰 sqlc doc

sqlc config file sample

version: 1
packages:
  - path: "db/sqlc"
    name: "db"
    engine: "postgresql"
    schema: "db/migration/"
    queries: "db/query"
    emit_json_tags: true
    emit_prepared_queries: false
    emit_interface: true
    emit_exact_table_names: false
    emit_empty_slices: true

genreate go code from sql query

sqlc generate

protoc & gRPC

install proto buffer compiler

🏠 protocolbuffers/protobuf

👉 download list

install Golang plugins for the protocol compiler:

go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2

Update your PATH so that the protoc compiler can find the plugins:

export PATH="$PATH:$(go env GOPATH)/bin"
# or write it to profile or zshrc file

evans

🏠 ktr0731/evans

👉 download list

evans is a gRPC client

# regsiter reflection

reflection.Register(grpcServer)

connect rpc server

evans -r repl --host <server address> --port <server port>

grpc-gateway

generate http server by protobuf and grpc 🏠 grpc-ecosystem/grpc-gateway

👉 download list

1 copy *.proto to project

// +build tools

package tools

import (
    _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway"
    _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2"
    _ "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
    _ "google.golang.org/protobuf/cmd/protoc-gen-go"
)
# pull dependencies
go mod tidy

# install binaries
go install \
    github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
    github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
    google.golang.org/protobuf/cmd/protoc-gen-go \
    google.golang.org/grpc/cmd/protoc-gen-go-grpc

add file to $PROJECT/proto/google/api/*.proto

🏠 googleapis/googleapis

google/api/annotations.proto
google/api/field_behavior.proto
google/api/http.proto
google/api/httpbody.proto

Documentation

Overview

Copyright © 2022 <st·kali clarkmonkey@163.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Directories

Path Synopsis
db
Package pb is a reverse proxy.
Package pb is a reverse proxy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL