module
0.0.0-20250128220202-be528c11f579
Repository: https://github.com/sh3lwan/gosocket.git
Documentation: pkg.go.dev
# README
GoSocket Backend Application
Overview
GoSocket is a backend application built with Go for managing real-time communication and backend services. This application serves as the core for handling API requests, WebSocket connections, and business logic for your project.
Features
- WebSocket Support: Efficient real-time communication using WebSockets.
- RESTful APIs: Endpoints for managing resources.
- Dockerized Deployment: Easily deployable with Docker.
- Scalable Architecture: Designed for scalability and high performance.
Getting Started
Prerequisites
Ensure you have the following installed:
- Go (v1.20 or later)
- Docker
- Docker Compose
Installation
-
Clone the repository:
git clone https://github.com/sh3lwan/gosocket.git cd gosocket
-
Build and run application using Docker:
go build -o gosocket ./cmd/chatapp/main.go
-
Run application locally:
./gosocket
Configuration
Environment Variables
Create a .env
file in the project root with the following variables:
APP_PORT=8080
DB_DATABASE=chat
DB_USERNAME=root
DB_PASSWORD=password
DB_HOST=mysql_db
DB_PORT=3306
DB_DRIVER=mysql
Docker Setup
-
Build and start the services:
docker-compose up --build
-
Access the application:
- REST API:
http://localhost:8000/api
- WebSocket:
ws://localhost:8000/ws
- REST API:
API Endpoints
RESTful APIs
Method | Endpoint | Description |
---|---|---|
GET | /api/health | Health check endpoint. |
POST | /api/login | Authenticate a user. |
WebSocket
- Endpoint:
/ws
- Handles real-time communication for clients.
Testing
Run unit tests using:
go test ./...
Update a .env.test
file in the project root with the following variables:
DB_DSN=:memory:
DB_DRIVER=sqlite3
Contributing
We welcome contributions! To contribute:
- Fork the repository.
- Create a new branch:
git checkout -b feature-name
- Commit your changes:
git commit -m "Add your message"
- Push to the branch:
git push origin feature-name
- Create a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgments
- Built with Go.
- Inspired by modern backend development best practices.