https://github.com/42lm/go-backend-skeleton
A minimal Go backend skeleton with a focus on few dependencies.
https://github.com/42lm/go-backend-skeleton
Last synced: 12 months ago
JSON representation
A minimal Go backend skeleton with a focus on few dependencies.
- Host: GitHub
- URL: https://github.com/42lm/go-backend-skeleton
- Owner: 42LM
- License: mit
- Created: 2025-07-17T18:05:02.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-21T19:24:15.000Z (12 months ago)
- Last Synced: 2025-07-21T21:26:20.352Z (12 months ago)
- Language: Go
- Homepage:
- Size: 90.8 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-backend-skeleton
This repository acts as a template for a simple go backend with the focus on not using too much external dependencies.
It utilizes:
* [spf13/cobra](https://github.com/spf13/cobra) to create a cli command to run the server
* [vektra/mockery](https://github.com/vektra/mockery) to generate mocks from interfaces
* [stretchr/testify](https://github.com/stretchr/testify) for simpler testing in general
* [42lm/muxify](https://github.com/42LM/muxify) for a better handling of the default `*http.ServeMux`
## Development
Copy `.envrc.example`
```sh
cp .envrc.example .envrc
```
> [!TIP]
> Use a tool like [direnv](https://github.com/direnv/direnv) to load and unload environment variables depending on the current directory.
Install tools (currently only mockery)
```sh
go install tool
```
Setup DB (currently only dynamodb)
```sh
docker compose up -d
```
Run tests
```
go test ./...
```
Run server
```sh
go run main.go server
```
Make a request
```sh
curl localhost:8080/v1/none
```
```sh
curl localhost:8080/v1/msg/777
```
```sh
curl -X POST localhost:8080/v2/msg/777 -d '{"msg":"test-msg"}'
```
### Generate mocks + proto
Generate mocks from interfaces with [mockery](https://vektra.github.io/mockery/latest/installation/) and use
```sh
go generate ./...
```
### Build
```sh
go build -ldflags "-X go-backend-skeleton/app/cmd.version=v0.0.0" -o gbs
```
### Troubleshoot
Make sure the following is installed on your machine. For more info check [protobuf](https://github.com/golang/protobuf).
* `brew install protobug`
* `brew install protoc-gen-go`
* `brew install protoc-gen-go-grpc`