All Projects → Aristat → golang-example-app

Aristat / golang-example-app

Licence: other
Example application

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to golang-example-app

Go-Gin-Api
基于golang开源框架 gin封装的api框架
Stars: ✭ 42 (-69.57%)
Mutual labels:  zap, viper, gorm, casbin
pink-lady
a template project of gin app.
Stars: ✭ 44 (-68.12%)
Mutual labels:  zap, viper, gorm
Go-Clean-Architecture-REST-API
Golang Clean Architecture REST API example
Stars: ✭ 376 (+172.46%)
Mutual labels:  zap, viper, jaeger
public
util toolkit for go.golang 通用函数包
Stars: ✭ 135 (-2.17%)
Mutual labels:  zap, gorm, cobra
go course
個人多年來學習與實作上的心得筆記
Stars: ✭ 25 (-81.88%)
Mutual labels:  protobuf, viper, cobra
Gin Web
由gin + gorm + jwt + casbin组合实现的RBAC权限管理脚手架Golang版, 搭建完成即可快速、高效投入业务开发
Stars: ✭ 107 (-22.46%)
Mutual labels:  viper, casbin
golangRestfulAPISample
Sample Restful app with chi router (golang)
Stars: ✭ 116 (-15.94%)
Mutual labels:  viper, wire
Ugin
UGin is an API boilerplate written in Go (Golang) with Gin Framework.
Stars: ✭ 110 (-20.29%)
Mutual labels:  viper, gorm
go-starter
Go 服务框架脚手架. 整合 echo、swag、viper、nsq、logrus、fx、xorm、cobra 等第三方库
Stars: ✭ 145 (+5.07%)
Mutual labels:  viper, cobra
Phalgo
phalgo 已经更换为 https://github.com/sunmi-OS/gocore phalgo不在维护
Stars: ✭ 110 (-20.29%)
Mutual labels:  viper, gorm
laracom
laracom driven by go micro services
Stars: ✭ 37 (-73.19%)
Mutual labels:  nats, viper
Go Todo
微信小程序 todo后端,采用GoFrame框架搭建,包含微信认证、token管理、发送微信模板消息等
Stars: ✭ 60 (-56.52%)
Mutual labels:  viper, gorm
Go Gin Api
基于 Gin 进行模块化设计的 API 框架,封装了常用功能,使用简单,致力于进行快速的业务研发。比如,支持 cors 跨域、jwt 签名验证、zap 日志收集、panic 异常捕获、trace 链路追踪、prometheus 监控指标、swagger 文档生成、viper 配置文件解析、gorm 数据库组件、gormgen 代码生成工具、graphql 查询语言、errno 统一定义错误码、gRPC 的使用 等等。
Stars: ✭ 730 (+428.99%)
Mutual labels:  viper, gorm
liftbridge-api
Protobuf definitions for the Liftbridge gRPC API. https://github.com/liftbridge-io/liftbridge
Stars: ✭ 15 (-89.13%)
Mutual labels:  protobuf, nats
savetheworldwithgo
Build systems with Go examples
Stars: ✭ 81 (-41.3%)
Mutual labels:  protobuf, cobra
rails-microservices-book
A guide to building distributed Ruby on Rails applications using Protocol Buffers, NATS and RabbitMQ
Stars: ✭ 23 (-83.33%)
Mutual labels:  protobuf, nats
Zeus Admin
Zeus基于Golang Gin +casbin,致力于做企业统一权限&账号中心管理系统。包含账号管理,数据权限,功能权限,应用管理,多数据库适配,可docker 一键运行。社区活跃,版本迭代快,加群免费技术支持。
Stars: ✭ 404 (+192.75%)
Mutual labels:  gorm, casbin
Irisadminapi
iris 框架的后台api项目
Stars: ✭ 544 (+294.2%)
Mutual labels:  gorm, casbin
Go Micro Boilerplate
The boilerplate of the GoLang application with a clear microservices architecture.
Stars: ✭ 147 (+6.52%)
Mutual labels:  protobuf, nats
Ts Proto
An idiomatic protobuf generator for TypeScript
Stars: ✭ 340 (+146.38%)
Mutual labels:  protobuf, dataloader

golang logo

Golang Example Application

Table of Contents

Overview

This is an example golang application. Commands list:

  1. Daemon - main service
  2. Product service - service that returns Product, an example of gRPC client/server interaction
  3. Health check service - this service is needed to show how convenient to understand on which of the services an error occurred in jaeger
  4. Migrate - commands for migration
  5. JWT - commands for generate JWT token

Package list

Packages which use in this example project

  1. sql-migrate - SQL migrations
  2. wire - dependency Injection
  3. viper - environment configuration
  4. cobra - create commands
  5. cast - easy casting from one type to another
  6. gorm - database ORM
  7. zap - logger
  8. mux - http router
  9. nats-streaming - NATS Streaming System
  10. gqlgen - graphql server library
  11. protobuf - Google's data interchange format
  12. grpc - RPC framework
  13. opentelemetry - OpenTelemetry
  14. jaeger - Jaeger Bindings for Go OpenTelemetry API
  15. casbin - Supports access control
  16. dataloaden - DataLoader for graphql
  17. nats - Golang client for NATS, the cloud native messaging system

Installing

Install the Golang and GO environment

https://golang.org/doc/install

Install Postgresql (if you want to run locally)

Clone repository

git clone [email protected]:Aristat/golang-example-app.git (go get)

Local environment

Install Golang packages without modules

make install

Install database

make createdb

Sql migrations

sql-migrate up

Install Golang dependencies

make dependencies

Generate artifacts(binary files and configs)

make build

Packages for proto generator

https://grpc.io/docs/languages/go/quickstart/#prerequisites

Set APP_WD if you start to use html templates or path to ssh keys or run make test

export APP_WD=go_path to project_path/resources or project_path/artifacts

Docker environment

Generate docker image

DOCKER_IMAGE=golang-example-app TAG=development make docker-image

Run services

Start in local machine

Up jaeger in docker-compose or disable Jaeger(and rebuild binary file) in resources/configs/*.yaml

docker-compose up jaeger

Start daemon (main service)

make start

or

./artifacts/bin daemon -c ./artifacts/configs/development.yaml -d

Start product service

./artifacts/bin product-service -c ./artifacts/configs/development.yaml -d

Start health-check service

./artifacts/bin health-check -c ./artifacts/configs/development.yaml -d

Start in docker

Run this commands

docker-compose rm # Remove previous containers
REMOVE_CONTAINERS=on DOCKER_IMAGE=golang-example-app TAG=development make docker-image # Generate new docker image
docker-compose up

or run script

./scripts/docker-compose-start.sh

Getting Started

Jaeger

http://localhost:16686

Http example with gRPC

http://localhost:9096/products_grpc

Http example with Nats Streaming

http://localhost:9096/products_nats

Http example with graceful shutdown(long request, you can check the server shutdown)

http://localhost:9096/products_slowly

Graphql example with gRPC

Graphql client for testing. End-point http://localhost:9096/query.

Generate JWT for Graphql authorization

./artifacts/bin jwt token --key='./artifacts/keys/local/private_key.pem' --fields='{"sub": "owner", "iss": "test-service"}'

Set JWT token in headers

{
  "Authorization": "bearer token"
}

Example query

query oneUser {
  users {
    one(email: "[email protected]") {
      email
      id
    }
  }
}

Example query with data loader

query allProducts {
  products {
    list {
      products {
        id
        productItems {
          id
          name
        }
      }
    }
  }
}

Example mutation

mutation createUser {
  users {
    createUser(email: "[email protected]", password: "123456789") {
      id
      email
    }
  }
}

Testing

➜  make test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].