golang-gin-realworld-example-app

command module
v0.0.0-...-728cb04 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: MIT Imports: 6 Imported by: 0

README

RealWorld Example App

Build Status codecov GoDoc

Golang/Gin codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

This codebase was created to demonstrate a fully fledged fullstack application built with Golang/Gin including CRUD operations, authentication, routing, pagination, and more.

Directory structure

.
├── gorm.db
├── hello.go
├── common
│   ├── utils.go        //small tools function
│   └── database.go     //DB connect manager
├── users
|   ├── models.go       //data models define & DB operation
|   ├── serializers.go  //response computing & format
|   ├── routers.go      //business logic & router binding
|   ├── middlewares.go  //put the before & after logic of handle request
|   └── validators.go   //form/json checker
├── ...
...

Getting started

Install Golang

Make sure you have Go 1.13 or higher installed.

https://golang.org/doc/install

Environment Config

Set-up the standard Go environment variables according to latest guidance (see https://golang.org/doc/install#install).

Install Dependencies

From the project root, run:

go build ./...
go test ./...
go mod tidy

Testing

From the project root, run:

go test ./...

or

go test ./... -cover

or

go test -v ./... -cover

depending on whether you want to see test coverage and how verbose the output you want.

Todo

  • More elegance config
  • Test coverage (common & users 100%, article 0%)
  • ProtoBuf support
  • Code structure optimize (I think some place can use interface)
  • Continuous integration (done)

Documentation

Overview

Golang Gonic/Gin startup project fork form RealWorld https://realworld.io

You can find all the spec and front end demo in the Realworld project

This project will include objects and relationships' CRUD, you will know how to write a golang/gin app though small perfectly formed.

Directories

Path Synopsis
The article module containing the article CRUD operation and relationship CRUD.
The article module containing the article CRUD operation and relationship CRUD.
Common tools and helper functions
Common tools and helper functions
The user module containing the user CRU operation.
The user module containing the user CRU operation.

Jump to

Keyboard shortcuts

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