Esta es una aplicación de ejemplo que utiliza el framework Fiber para crear una API que se conecta a una base de datos SQL Server.
- Go 1.16 o superior
- SQL Server
- Archivo
.envcon las siguientes variables:DB_USER: Usuario de la base de datosDB_PASSWORD: Contraseña de la base de datosDB_SERVER: URL del servidor de la base de datosDB_PORT: Puerto del servidor de la base de datosDB_DATABASE: Nombre de la base de datos
-
Clona el repositorio:
git clone https://github.com/matigumma/go-fiber-sql-hexagonal.git cd go-fiber-sql-hexagonal -
Instala las dependencias:
go mod tidy
-
Crea un archivo
.enven la raíz del proyecto con las variables de entorno necesarias.
-
Inicia la aplicación:
go run main.go
-
La aplicación estará disponible en
http://localhost:3000.
- TODO
main.go: Archivo principal de la aplicación.public/: Directorio para archivos estáticos.internal/: Código interno de la aplicación.app/: Lógica de la aplicación.api/: Lógica del caso de uso.
ports/: Interfaces de los puertos.adapters/: Implementaciones de infraestructura.left/: Driving side.rest/: Servicio Rest.
right/: Driven side.db/: DB adapter.
This project uses a Makefile to manage common tasks. Below are the available commands:
APP_NAME: The name of the application (default:go-fiber-sql-hexagonal)VERSION: The version of the application (default:0.0.1)GO_CMD: The Go command (default:go)CGO_ENABLED: CGO enable flag (default:0)
Builds the project with CGO disabled and outputs the binary to the ./build directory with the name $(APP_NAME)-dev.
Runs all tests in the project with CGO disabled.
Cleans up the binary files and removes the ./build directory.
Builds the production binary with CGO disabled, using the current OS and architecture. The binary is output to the ./build/production directory with the name $(APP_NAME)-$(VERSION).
-
To build the project:
make build
-
To run tests:
make test -
To clean up binaries:
make clean
-
To create a production release:
make release
- Ensure you have Go installed and properly set up in your environment.
- The
CGO_ENABLEDvariable is set to0by default to disable CGO. You can modify this if your project requires CGO.