Skip to main content
gFly v1.15.1
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Installation

Install Golang

Before installing Go, ensure your system meets the minimum requirements:

  • Disk space: ~400MB
  • Operating system: Windows, macOS, or Linux

1. On Linux

# Install go at folder /home/$USER/Apps
mkdir -p /home/$USER/Apps
wget https://go.dev/dl/go1.24.2.linux-amd64.tar.gz
tar -xvzf go1.24.2.linux-amd64.tar.gz

Add bottom of file ~/.profile or ~/.zshrc

vi ~/.profile

# ----------- Golang -----------
export GOROOT=/home/$USER/Apps/go
export GOPATH=/home/$USER/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Check

source ~/.profile
# Or
source ~/.zshrc

# Check Go
go version

2. On Mac

# Install go at folder /Users/$USER/Apps
mkdir -p /Users/$USER/Apps
wget https://go.dev/dl/go1.24.3.darwin-arm64.tar.gz
tar -xvzf go1.24.3.darwin-arm64.tar.gz

Add bottom of file ~/.profile or ~/.zshrc

vi ~/.profile

# ----------- Golang -----------
export GOROOT=/Users/$USER/Apps/go
export GOPATH=/Users/$USER/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Check

source ~/.profile
# Or
source ~/.zshrc

# Check Go
go version

Install Tools

There are many tools to support coding, proofing, diagnostics, and suggestions to help make the final product highly effective. gFly also uses those tools as a necessary part of the application development process. We encourage you to install and use them.

Note
IMPORTANT!
You should install all the below CLIs to ensure the Makefile's execution commands are fully implemented.

The following tools are essential for modern Go development:

  • gocritic - Finds code style issues, inefficient constructs, logical errors and suggests improvements:

    go install github.com/go-critic/go-critic/cmd/gocritic@latest
    gocritic version
    
  • gosec - Security checker that scans for common vulnerabilities:

    go install github.com/securego/gosec/v2/cmd/gosec@latest
    gosec version
    
  • govulncheck - Analyzes code for known vulnerabilities:

    go install golang.org/x/vuln/cmd/govulncheck@latest
    govulncheck -version
    
  • golangci-lint - Fast and highly configurable linter aggregator:

    go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
    golangci-lint --version
    
  • swag - Automatically generates Swagger/OpenAPI 2.0 documentation:

    go install github.com/swaggo/swag/cmd/swag@latest
    swag -v
    
  • migrate - Database migration tool supporting multiple databases:

    go install -tags 'postgres mysql' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
    migrate --version
    
  • air - Live reload tool that rebuilds and restarts your app when files change:

    go install github.com/air-verse/air@latest
    air -v
    

These tools can be installed using the provided go install commands. For proper functionality, ensure your Go bin directory is in your system PATH.

Install Docker

Make sure you have Docker installed on your machine. You can use Docker Desktop for all three environments: Mac, Linux, and Windows. You can refer to the suggestions below.

For the Windows environment, use WSL2 (Windows Subsystem for Linux) and install Ubuntu App from Microsoft Store. You will have completely Linux env

On the Linux environment (Ubuntu). If you are too familiar with Docker. Then there is no need to install Docker Desktop. Using the command line also helps save resources on the computer.

Note
TIP on Mac
On the Mac environment, you should use OrbStack instead of Docker Desktop because it has certain benefits. Can help you run faster and more conveniently when using DNS for each docker instance.

Creating A Project with gFly

Checkout the latest gFly codebase:

git clone https://github.com/jivegroup/gfly.git myweb
cd myweb 
rm -rf .git* 
cp .env.example .env
ls -la

Makefile Commands

The project includes several Makefile commands to simplify development:

Note: The Make tool is required for projects on Mac, Linux, and Windows as well.

Command Description
make all Check code style, security, lint, run tests, generate documentation, and build the application
make check Run code style checks, security checks, vulnerability checks, and linting
make lint Run golangci-lint on all packages
make critic Run gocritic checks on the codebase
make security Run gosec security checks on the codebase
make vulncheck Run govulncheck to check for vulnerabilities
make test Run all tests with coverage reporting
make test.coverage Display test coverage in browser
make build Build the application and CLI tool
make run Run linting, tests, generate documentation, build and run the application
make start Alias for make run
make schedule Build and run the scheduler
make queue Build and run the queue worker
make migrate.up Run database migrations
make migrate.down Revert database migrations
make dev Run the application in development mode with hot reloading
make stop Force stop web app by port
make clean Clean up the project (tidy go.mod, clean cache)
make doc Generate API documentation using Swag
make container.run Start required Docker containers (PostgreSQL, Redis, Mail)
make container.logs View logs from Docker containers
make container.stop Stop Docker containers
make container.delete Remove Docker containers
make upgrade Upgrade all Go dependencies
make api.scripts Generate API shell scripts from Swagger file

Start app

# Run docker instances for Database, Redis, Mail
make docker.run

# Run web in local
make doc
make dev

And also run docker.logs to help you have a quick view of running status.

Check docker instances were created.

docker ps                                                                                                                                                                                                                                       ─╯

CONTAINER ID   IMAGE                  COMMAND                  CREATED        STATUS                        PORTS                                                                                            NAMES
aaf7e08799c3   axllent/mailpit        "/mailpit"               46 hours ago   Up About a minute (healthy)   0.0.0.0:1025->1025/tcp, :::1025->1025/tcp, 0.0.0.0:8025->8025/tcp, :::8025->8025/tcp, 1110/tcp   gfly-mail
5a2f731e73ae   redis:7.4.0-alpine     "docker-entrypoint.s…"   10 days ago    Up About a minute             0.0.0.0:6379->6379/tcp, :::6379->6379/tcp                                                        gfly-redis
1faddf43f32d   postgres:16.4-alpine   "docker-entrypoint.s…"   10 days ago    Up About a minute (healthy)   0.0.0.0:5432->5432/tcp, :::5432->5432/tcp                                                        gfly-db

Note: A new network name gfly_default was created.

Check app

curl -v -X GET http://localhost:7789/api/v1/info | jq

CLI Actions

Run below commands in 3 different terminals

# Build app & cli tools
make build

# -------- Schedule ---------
# Run schedule (Terminal 1)
# Note: Will get the message of `Schedule Job` file `hello_job.go` every 2 seconds
./build/artisan schedule:run

# ---------- Queue ----------
# Run queue (Terminal 2)
# Note: Nothing happens because don't have any job was queued!
./build/artisan queue:run

# --------- Command ---------
# Run command `hello-world` (Terminal 3)
./build/artisan cmd:run hello-world