Template Fiber framework project for fast prototyping, trial, or micro-service unit usage.
Make sure that you have Golang installed already.
- GORM as ORM, to operate with Postgre database
- Redis as Cache, etcd can also be a good choice
- NATS as Message Queue
- InfluxDB for Time Series Data (logs, etc.)
GQLGen as GraphQL
You can safely skip this part if not approaching the internet from within mainland China.
go env -w GOPROXY=https://goproxy.io,direct # Official
go env -w GOPROXY=https://goproxy.cn,direct # QiniuCloud/七牛云
go env GOPROXY # Double check- Root: http://127.0.0.1:3000/api/v1/
- Demo with Posts model: http://127.0.0.1:3000/api/v1/post
- Root: http://127.0.0.1:3000/graphql/
- Demo is not available for now
curl -X POST \
http://127.0.0.1:3000/graphql/ \
-H 'Content-Type: application/json' \
-d '{
"query": "query { posts { id name } }"
}'Create a trial-fiber database (you can use another name, just config it in the .env file) in PostgreSQL/MySQL/MariaDB of yours, then follow these steps below.
# Create .env file
cp .env.sample .env # at least specify a database connection info
# Install dependencies
go get ./...
# [Optional] Update dependencies
go get -u ./...
go mod tidyWithout live-reloading
go run ./src/...With live-reloading (via air-verse/air)
# Install Air
go install github.com/air-verse/air@latest
# Run with
air # Linux/macOS
air -c .air.windows.toml # Windows
For more detailed instructions, e.g. solutions on working cross OS, checkout https://manual.kamaslau.com/golang/tools/air.html.
Remember to put a .env file in to the same directory with the executable file compiled
go build -o ./dist/main ./src
docker build . -t trial-fiber:latest
docker network create trial-backend && \
docker stop trial-fiber && \
docker rm trial-fiber && \
docker run --name trial-fiber --network trial-backend -p 3000:3000 -d --restart always --net=host trial-fiber:latestMake sure that other service components (database, cache, MQ, etc.) are within the same network, e.g.,
docker network connect trial-backend trial-fiber
docker network connect trial-backend database-xxx
docker network connect trial-backend mq-xxx