You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

github.com/tech-dex/partspal

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/tech-dex/partspal

v0.0.0-20230911153301-c4a26ae5abbb
Source
Go
Version published
Created
Source

PartsPal

Whether you're a car enthusiast, a mechanic, or a regular vehicle owner, PartsPal is designed to help you quickly find the exact parts you need for your vehicle maintenance or repair projects.

Features

  • Search and compare car parts from multiple providers
  • Real-time price and availability updates
  • User-friendly Fyne desktop application
  • Websocket API for easy integration into other applications

Getting Started

Prerequisites

  • Go (version 1.16 or higher)
  • Fyne (installation guide: https://github.com/fyne-io/fyne)
  • Gorilla Websocket (installation guide: https://github.com/gorilla/websocket)

Installation

  • Clone the repository:
git clone <repository-url>
  • Install dependencies:
go mod download

3.1. Build the Fyne application:

go build cmd/parts-pal/main.go

3.2. Build the Websocket server:

go build cmd/api/main.go
  • Run the built executables:
./main
  • Packaging the Fyne application (optional):
fyne package -os <operating-system> -icon <icon-file> # https://developer.fyne.io/started/packaging

Usage

Fyne Application

  • Run the Fyne application:
./main
  • Enter the product code information and click the "Search" button

Websocket API

  • Run the Websocket server:
./main
  • Connect to the server using a websocket client on localhost:3000/ws/scrape
  • Send a simple byte message containing the product code information: "27025"
  • The server will respond with a JSON message containing the product information. There are 2 types of messages: " bestDeal" and "deal"
  • The "bestDeal" message contains the best deal for the product, while the "deal" message contains a deal from one of the providers

Example WebSocket Client Code (using Gorilla Websocket):

package main

import (
	"log"

	"github.com/gorilla/websocket"
)

func main() {
	// Establish a WebSocket connection
	conn, _, err := websocket.DefaultDialer.Dial("ws://localhost:3000/ws/scrape", nil)
	if err != nil {
		log.Fatal(err)
	}
	defer conn.Close()

	// Send a simple message with the product code
	err = conn.WriteMessage(websocket.TextMessage, []byte("PRODUCT_CODE"))
	if err != nil {
		log.Fatal(err)
	}

	// Receive and handle WebSocket messages
	for {
		_, message, err := conn.ReadMessage()
		if err != nil {
			log.Fatal(err)
		}
		// Handle the received message
		log.Println("Received message:", string(message))
	}
}

Replace "PRODUCT_CODE" in the code above with the actual product code you want to search for.

FAQs

Package last updated on 11 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts