https://github.com/dimuska139/golang-api-skeleton
Base API skeleton to create applications with Golang.
https://github.com/dimuska139/golang-api-skeleton
gin-gonic go golang gomodules google-wire pkger viper
Last synced: 3 months ago
JSON representation
Base API skeleton to create applications with Golang.
- Host: GitHub
- URL: https://github.com/dimuska139/golang-api-skeleton
- Owner: dimuska139
- Created: 2020-08-09T17:40:29.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-03-18T11:47:44.000Z (about 3 years ago)
- Last Synced: 2025-01-08T22:09:28.841Z (4 months ago)
- Topics: gin-gonic, go, golang, gomodules, google-wire, pkger, viper
- Language: Go
- Homepage:
- Size: 55.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DEPRECATED! See [go-api-layout](https://github.com/dimuska139/go-api-layout) please
# Golang API skeleton
* Config file reading ([viper](github.com/spf13/viper))
* Migrations ([golang-migrate](https://github.com/golang-migrate/migrate))
* Compile-time Dependency Injection ([google/wire](https://github.com/google/wire))
* Working with database (where is no [GORM](http://gorm.io/index.html) in this skeleton but you can easily integrate it)
* Token-Based Authentication (with sliding sessions)Tests will be soon :)
## Migrations
1. [Create migration file](https://github.com/golang-migrate/migrate/blob/master/MIGRATIONS.md) in `/migrations` directory
(also you can use [CLI](https://github.com/golang-migrate/migrate#cli-usage) for it).
1. Build your application.
1. Migrations applying automatically after you run compiled binary file.## Dependency injection
[google/wire](https://github.com/google/wire) - DI without magic and run-time reflection.
To append new service to initialization you should:
1. Create service and "provider" for it (see **NewUsersAPI** in `/api/users.go` for example).
1. Inject provider to initialization in `wire.go` (first line `//+build wireinject` is definitely needed)
1. Run `wire` command to generate `wire_gen.go` (file with generated initialization steps)
1. Build/Run your appAlso you can read detailed [tutorial](https://github.com/google/wire/blob/master/_tutorial/README.md).