Optical is a CLI tool that generates a Go Fiber project template. It is inspired by express-generator, a tool that produces a Node.js project template for the Express.js framework.
It is named Optical because it works with Fiber and combines 'fiber-optic'. Silly.
🔵 Although there are big-scale CLI tools exist like create-go-app to help you create Full-Stack Apps using Go and JS/TS, optical is just a fiber-dependent CLI tool to generate API/Backend only.
If you do not have Go installed on your device, you are required to install it to run this tool.
You can install Optical CLI using Go:
go install github.com/tuhinexe/optical@latest
Or you can use our installation script:
curl -sSL https://raw.githubusercontent.com/tuhinexe/optical/main/scripts/install.sh | bash
To create a new Optical project:
optical -create
Optical CLI version 1.0.0
┃ What is the name of your project?(e.g 'my-fiber-api','./')
┃ A new folder with this name will be created.
┃ > <your-project-name>
Enter your GitHub username.
This is required to create the go.mod file
> <your-gitub-username>
Do you have air installed?
Air is required for auto-reload
Yes
> No
enter next
or
To get help and see all the flags:
optical -h
After creating the project run this:
cd <your-project-name>
go mod tidy
air
It will run your Fiber App and the output should look like this:
Optical generates the starting files for your project. You can configure your project folder and files according to your requirements.
To set up your project further, refer to the Fiber Official Docs
If you run a command like:
optical -create
Optical CLI version 1.0.0
┃ What is the name of your project?(e.g 'my-fiber-api','./')
┃ A new folder with this name will be created.
┃ > cyber-fiber
Enter your GitHub username.
This is required to create the go.mod file
> tuhinexe
Do you have air installed ?
Air is required for auto-reload
Yes
> No
enter next
It will create a new Optical project in a directory named cyber-fiber
with go.mod
like this :
module github.com/tuhinexe/cyber-fiber
go 1.23
require (
github.com/gofiber/fiber/v2 v2.52.5
github.com/joho/godotenv v1.5.1
github.com/lib/pq v1.10.9
go.mongodb.org/mongo-driver v1.16.1
)
Please refer to USAGE.md for more detailed usage instructions.
We welcome contributions! Please see CONTRIBUTING.md for details on how to contribute to this project.
This project is licensed under the MIT License - see the LICENSE file for details.