Coder Social home page Coder Social logo

kyfk / golang-todo-list-sample Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 8.08 MB

A simple backend application for Todo List apps in written Go.

Go 95.47% Shell 4.53%
clean- entgo go grpc-gateway grpc-go protobu protoc-gen-go protoc-gen-validate todo

golang-todo-list-sample's Introduction

golang-todo-list-sample

A simple backend application for Todo List apps written in Go.

Concept of this repository

Schemaful Generation

I want to suggest to you how to develop a modern backend application written in Go.

My concept is Schemaful Generation, which prevents tired duplicated codes. The DRY principle is one of the essential theories.

The expression of Go is poorer than Ruby, Java, Rust, or other popular programming languages because Go doesn't have functional Generics, Trait, Macro, Enum, or more modern programming language features.

That means you need to write a lot of commonalize lines explicity. Usually, explicity helps you easier than implicitly to debug your application codes, however, that is hard and boring (at least to me). Imagine, if you implement a new REST API endpoint in an application, you may define REST API, then you need to write OpenAPI spec to share with front-side engineers. You may add a path to a server, create a request structure, implement request validation logic... and so on.

You know, everyone wants to focus only on implementing business logic. So I really recommend you generate from schemas. Protocol Buffer is one of those tools.

There's a lot of schema generation libraries using go generate.

I'd like to introduce you how to build a backend application by schema generation using Protocol Buffer(gRPC/protoc-gen-validate/grpc-gateway) and entgo.

Layered Architecture

SOLID principle introduces well-testable and well-maintenable codes.

Layered Architecture is a method that you to follow the principles and gives regularity among your team.

This project inspired by Clean Architecture.

First of all, let me say the name of layers is not matter.

  • Usecase {pkg/usecase}
  • Repository {pkg/repo, pkg/usecase/repo}
  • Presenter {pkg/presenter}

Migration

You need to run MySQL in local environment.

I recoomend to launch that using Docker as below.

docker run -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=true mysql:8 --sql-mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

Then, run the scripts to generate migration file resolving dependencies from previous migration files.

go run ./tools/gen_migration.go {Input migration file name you'd like to be}

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.