Skip to content

Latest commit

 

History

History
75 lines (55 loc) · 1.92 KB

README.md

File metadata and controls

75 lines (55 loc) · 1.92 KB

trial-fiber

License: MIT Repository size

Template Fiber framework project for fast prototyping, trial, or micro-service unit usage.

Make sure that you have Golang installed already.

[🇨🇳 Optional] Setup Mirror for Mainland China

You can skip this one 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

Usage

# Create .env file
cp .env.sample .env # specify database connection info

# Install dependencies
go get ./src

# [Optional] Update dependencies
go get -u ./src
go mod tidy

# Run
## With live-reloading (via air-verse/air)
### Install and config air
go install github.com/air-verse/air@latest
air init
### Change the .air.toml file generated
#### macOS/Linux
[build]
bin = "./tmp/main"
cmd = "go build -o ./tmp/main ./src"
#### Windows
[build]
bin = "tmp\\main.exe"
cmd = "go build -o ./tmp/main.exe ./src"
### Use
air

## Without live-reloading
go run src/main.go

# Compile
## Remember to put a .env file in to the same directory with the executable file compiled
go build -o ./dist/main ./src

Deploy with docker

docker build . -t trial-fiber:latest

docker stop trial-fiber && \
docker rm trial-fiber && \
docker run --name trial-fiber -p 3000:3000 -d --restart always --net=host trial-fiber:latest

References/Credits