Coder Social home page Coder Social logo

goapi's Introduction

goapi

go1.22+

This is a template for creating a REST API using Golang, Gin, Gorm, Zap, and Swagger.

Features

  • Support databases: MySQL, PostgreSQL, and SQLite databases
  • Support docker
  • Performance optimization
  • Redoc and openapi documentation
  • Full chain trace of logs (use uber-zap)
  • Lightweight and fast
  • Licensed under the MIT License

Installation

  1. Clone the repository:
git clone https://github.com/atopx/goapi.git
  1. Init your app
cd goapi
./control init $NEW_NAME # example: ./control init newapp
  1. Change the configuration file:
cp conf/config.example.yaml conf/config.yaml
  1. Run the application:
go mod tidy
go run main.go
  1. Control script
./control { init $NEW_NAME | build | docker | docs | clean }

Codes Layout

goapi
├── common # common package
│   ├── handle # global handlers
│   │   └── db.go
│   ├── logger # global logger
│   │   ├── gorm.go
│   │   └── logger.go
│   ├── middleware # router middleware
│   │   ├── context.go
│   │   └── recover.go
│   ├── system # api response
│   │   ├── consts.go
│   │   └── response.go
│   └── utils # frequently used functions
│       ├── sql.go
│       └── trace.go
├── conf # configuration file
│   ├── config.example.yaml
│   ├── config.go
│   └── config.yaml
├── docs # redoc and openapi documentation
├── internal # internal logic
│   ├── api # define api
│   │   ├── server.go
│   │   └── user.go
│   ├── biz # business logic
│   │   └── user
│   │       └── list
│   │           ├── action.go
│   │           └── schema.go
│   ├── control # api controller interface
│   │   └── control.go
│   ├── model # db model
│   │   └── user.go
│   ├── server # api server
│   │   ├── router.go
│   │   └── server.go
│   └── worker # async workers
│       ├── health
│       │   └── task.go
│       └── worker.go
├── pkg # third-party packages
│   ├── db.go
│   └── redis.go
└── tests # tests
    └── config_test.go

goapi's People

Contributors

atopx avatar

Stargazers

 avatar

Watchers

 avatar

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.