https://github.com/agalitsyn/go-app
Go applications in one repository
https://github.com/agalitsyn/go-app
api-rest go
Last synced: 4 months ago
JSON representation
Go applications in one repository
- Host: GitHub
- URL: https://github.com/agalitsyn/go-app
- Owner: agalitsyn
- Created: 2016-05-26T08:35:10.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-03-12T15:16:55.000Z (over 2 years ago)
- Last Synced: 2025-12-17T13:33:03.563Z (7 months ago)
- Topics: api-rest, go
- Language: Go
- Homepage:
- Size: 3.08 MB
- Stars: 20
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-app
* Ready for creating Go applications in one repository.
* Includes example of RESTful API service, but you can add more service types, for example workers, consumers, etc.
* Go 1.16 + docker + docker-compose - easy setup on own server. No CI server required, just `make docker-export` and `scp` to your server.
## Repository structure
* Structure supports multiple services:
* Each service has own directory in `cmd` folder for `main` function, which typically consists of dependencies and service start.
* Service logic with tests are in `internal/app`.
* Shared packages are in `internal/pkg`.
* Storage entities and interfaces are in `internal/storage`. Interfaces can have multiple implementations of storages types like `internal/storage/{rdb,memory,kv,object,document}`.
* All applications build in one docker image for easy distribution, so you should define explicit `command` in `docker-compose` or in k8s files for each service.
## Migrations
This template includes `PostgreSQL` connector, with [tern](https://github.com/jackc/tern) migrator. Check `migrations` folder.
## Quickstart
```bash
make docker-build
docker-compose up
make migrate
# test it
curl -i -X POST localhost:8080/1.0/articles --data '{"title": "New Book", "slug": "new-book"}'
curl -i -X GET localhost:8080/1.0/articles
```
## Local development
```bash
cp .env.example .env.local
docker-compose up postgres
make migrate
make run
```
### Testing
* Service tests with mocked storages are in `internal/app`.
* Storage tests are in `internal/storage`.
For testing postgres storages run `docker-compose up postgres`. Can be skipped with `make test-short`.