GithubHelp home page GithubHelp logo

ruilisi / go-pangu Goto Github PK

View Code? Open in Web Editor NEW
45.0 6.0 17.0 1.59 MB

rest api web server based on go(High availability, high security, high performance)

License: MIT License

Go 83.21% Dockerfile 0.30% Makefile 2.78% Shell 3.96% HTML 3.61% CSS 1.95% TypeScript 4.18%
go rest rest-api restful-api go-server golang postgres redis gorm backend rest-server api-server

go-pangu's Introduction

Golang-pangu

中文文档

Go-pangu is a Go boilerplate which follows cutting-edge solutions already adopted by the industry, JWT(JSON Web Tokens), Postgres, Redis, Docker, Gin, Ginkgo, Gorm. It is a solid production-ready starting point for your new backend projects.

Features

Golang-pangu is based on following tools

name description
Go an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gin web struct based on Go, flexible middleware,strong data binding and outstanding performance.
Gorm The fantastic ORM library for Golang aims to be developer friendly.
Ginkgo Ginkgo builds on Go's testing package, allowing expressive Behavior-Driven Development ("BDD") style tests.
JWT JSON Web Tokens. An open, industry standard RFC 7519 method for representing claims securely between two parties.
Postgres The world's most advanced open source relational database
Redis An open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker.
Docker Docker is a tool designed to make it easier to create, deploy, and run applications by using containers.

Struct

.
├── application.yml  
├── args
│   ├── args.go
│   └── cmd.go
├── conf  
│   ├── conf_debug.go
│   ├── conf.go
│   └── conf_release.go
├── controller
│   ├── application.go
│   ├── auth.go
│   ├── error.go
│   └── session.go
├── db  
│   └── db.go
├── Dockerfile
├── go.mod
├── go.sum
├── jwt  
│   └── jwt.go
├── main.go
├── Makefile  
├── middleware  
│   └── middleware.go
├── models  
│   ├── base_model.go
│   └── user.go
├── params  
│   └── params.go
├── README.md
├── redis
│   └── redis.go
├── routers  
│   └── router.go
├── test
│   ├── sign_in_test.go
│   └── test_suite_test.go
└── util
    └── util.go
file function
application.yml config file
args functions which can fetch params from request url
conf functions which can get configurations
controller handlers
db database operations like migrating database
jwt fuctions to create and check jwt
main.go main function.Call function with "--db" parameter, "create" to create database, "migrate" to migrate tables, "dorp" to delete database
middleware middleware
models base models and basic database operations
params struct used in data binding
redis redis connection and operations
router router
test test
i18n internationalization
influx influx operations include read/save point

Start

  1. install postgres, redis
  2. config application.yml
`make create`(create database) or `go run main.go -db=create`
`make migrate`(migrate tables) or `go run main.go -db=migrate`
`make watch`(with hot reload) or `go run main.go`
  1. open http://localhost:3002/ping in web browser, and then you will get a "pong" response

Api examples

  • sign_up

    Post http://localhost:3002/users/sign_up

    params: email, password, password_confirm

    Register user

  • sign_in

    Post http://localhost:3002/users/sign_in

    params: email, password, DEVICE_TYPE, login_type

    You will get a header with authorization parameter from response after logging in successfully

  • auth_ping

    Get http://localhost:3002/auth_ping

    Should add a valid user token to request this api

  • change_password

    Post http://localhost:3002/users/change_password

    params: origin_password, password, password_confirm

    Modify user's password, which needs authorization

  • cities

    Post http://localhost:3002/cities

    params: language

    set language to en, return cities in English. set language to zh, return cities in Chinese.

sms api

(Tencent service, need to set your key in application.yml )

  • sms

    Get http://localhost:3002/sms

    params: mobile

    send sms

influx apis

(need to install influxdb and modify main.go)

  • influx_save

    Post http://localhost:3002/influx_save

    params: user_name, local, version

    save struct in influxdb

  • influx_show

    Post http://localhost:3002/influx_save

    get struct message in influxdb

pay apis

(Alipay service, need to set you key in application.yml)

  • alipay

    Post http://localhost:3002/alipay

    create alipay bill

  • alipay_notify

    Post http://localhost:3002/alipay_notify

    receive pay details notify

other public library

Rails-pangu is a Rails 6(API Only) boilerplate which follows cutting-edge solutions already adopted by the industry, notablly, Devise, JWT(JSON Web Tokens), Postgres, Redis, Docker, Rspec, RuboCop, CircleCI. It is a solid production-ready starting point for your new backend projects.

Projects using Go-pangu

product description
eSheep Network booster which helps global users access better entertainment content from China.
cs-server agent server(Comming soon!)
soda-server Comming soon!

License

Code and documentation copyright 2020 the Golang-pangu Authors and ruilisi Network Code released under the MIT License.

hophacker

Contributors

Thanks goes to these wonderful people (emoji key):

hophacker
hophacker

💻 📖 🚇
tony
Tony

💻 📖
Ganggou
Ganggou

💻 📖
Xingo
ExcitingFrog

💻 📖
Leo7991
Leo7991

💻 📖
Daxigua443
Daxigua443

💻 📖
Soryu23
Soryu23

💻 📖

This project follows the all-contributors specification. Contributions of any kind welcome!

go-pangu's People

Contributors

bphaofan avatar excitingfrog avatar ganggou avatar hophacker avatar leo7991 avatar soryu23 avatar tony2100 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

go-pangu's Issues

好像和配置项不吻合

baseDb, err := gorm.Open(postgres.Open(uri.String()), &gorm.Config{})

我配置是这样的:DATABASE_URL: postgres://test_user:123456@localhost:5432/go_pangu_development?sslmode=disable
运行后提示这个错,调试了很久跑步起来,感觉有问题,帮忙看下啥原因
2020/12/30 18:03:33 /home/go-pangu/db/db.go:40
[error] failed to initialize database, got error failed to connect to host=localhost user=test_user database=: server error (致命错误: 数据库 "test_user" 不存在 (SQLSTATE 3D000))
panic: failed to connect to host=localhost user=test_user database=: server error (致命错误: 数据库 "test_user" 不存在 (SQLSTATE 3D000))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.