Categorygithub.com/sh3lwan/gosocket
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:

Installation

  1. Clone the repository:

    git clone https://github.com/sh3lwan/gosocket.git
    cd gosocket
    
  2. Build and run application using Docker:

    go build -o gosocket ./cmd/chatapp/main.go
    
  3. 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

  1. Build and start the services:

    docker-compose up --build
    
  2. Access the application:

    • REST API: http://localhost:8000/api
    • WebSocket: ws://localhost:8000/ws

API Endpoints

RESTful APIs

MethodEndpointDescription
GET/api/healthHealth check endpoint.
POST/api/loginAuthenticate 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:

  1. Fork the repository.
  2. Create a new branch:
    git checkout -b feature-name
    
  3. Commit your changes:
    git commit -m "Add your message"
    
  4. Push to the branch:
    git push origin feature-name
    
  5. 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.

# Packages

No description provided by the author
No description provided by the author