Giter Site home page Giter Site logo

sallamy2580 / go-web-project-main-flow Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 696 KB

Golang Skeleton With Fully Managed Versions For Kick Start GoLang Project Development

Home Page: https://www.mindinventory.com/blog/golang-project-structure/

License: MIT License

Shell 2.66% Go 90.88% HTML 6.46%
easy-to-use go-framework go-gin go-jwt go-playground golang golang-library golang-package golang-server golang-skeleton

go-web-project-main-flow's Introduction

Golang Skeleton With Fully Managed Versions For Kick Start GoLang Project Development

License: MIT

There is no doubt that Golang’s good documentation and intelligent features could help developers in learning language efficiently and outcome might be promising still, What Golang is missing is the common structure to quick start any API Structure. While working on several Golang Projects, Golang Developers at Mindinventory confront the requirement of having an effective and well Integrated GoLang API Development Structure and as a result of which they came up with one.

  • gorm : It is the ORM library in Go which provides user friendly functions to interact with database. It supports features like ORM, Associations, Hooks, Preloading, Transaction, Auto Migration, Logger etc.
  • gin : Gin is a web framework for Go language. Here gin is used for increase performance and productivity.
  • godotenv : Basically used for load env variables from .env file.
  • mysql : It provides the mysql driver for connecting Go with MySQL.

Check out our blog to know how to use Golang API Skeleton with Fully Managed Versions to kick start Golang project. (https://www.mindinventory.com/blog/golang-project-structure/)

STRUCTURE

What it is?

It is a fully managed repository, where one can find all required components in a single package including versioning for REST APIs and you do not need to set up each time they start with any crucial work in Golang.

Prerequisite

One need to install the latest version of Go i.e 1.12 (Released in Feb 2019) from https://golang.org/dl/ and setup GOROOT and GOPATH.

Components

1. ApiHelpers

Basically contains the helper functions used in returning api responses, HTTP status codes, default messages etc.

2. Controllers

Contains handler functions for particular route to be called when an api is called.

3. Helpers

Contains helper functions used in all apis

4. Middlewares

Middleware to be used for the project

5. Models

Database tables to be used as models struct

6. Resources

Resources contains all structures other than models which can be used as responses

7. Routers

Resources define the routes for your project

8. Seeder

It is optional, but if you want to insert lots of dummy records in your database, then you can use seeder.

9. Services

All the core apis for your projects should be within services.

10. Storage

It is generally for storage purpose.

11. Templates

Contains the HTML templates used in your project

12. .env

Contains environment variables.

Steps to Follow

. For running the server you have to run following command in the terminal. go run main.go It will start your server at the port you have mentioned in the .env file.

. To run the server in a port other than the default, run following command. go run main.go <specific port>

. To create a build for your project and uploaded in the server, one need to run following command. go build

API with versioning

For using version 1 api

127.0.0.1:8099/api/v1/user-list

For using version 2 api

127.0.0.1:8099/api/v2/user-list

LICENSE!

Go Project Structure is MIT-licensed

Let us know!

We’d be really happy if you sent us links to your projects where you use our component. Just send an email to [email protected] And do let us know if you have any questions or suggestion regarding our work.

go-web-project-main-flow's People

Contributors

sallamy2580 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.