From 3c74f4793dfce30af4b7f574fbd846e8716994da Mon Sep 17 00:00:00 2001 From: Dimas Restu H Date: Sat, 21 May 2022 13:34:34 +0700 Subject: [PATCH] update README.md for proper reading --- README.md | 112 ++++++++++++++++++++++++++++++--------- pkg/whatsapp/whatsapp.go | 3 +- 2 files changed, 88 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index f3f5013..105c1e3 100644 --- a/README.md +++ b/README.md @@ -1,70 +1,130 @@ # Go WhatsApp Multi-Device Implementation in REST API -This repository contains example of implementation [go.mau.fi/whatsmeow](https://go.mau.fi/whatsmeow/) package. This example is using a [labstack/echo](https://github.com/labstack/echo) version 4.x. +This repository contains example of implementation [go.mau.fi/whatsmeow](https://go.mau.fi/whatsmeow/) package with Multi-Session/Account Support. This example is using a [labstack/echo](https://github.com/labstack/echo) version 4.x. ## Getting Started These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. -See deployment for notes on how to deploy the project on a live system. +See deployment section for notes on how to deploy the project on a live system. ### Prerequisites -Prequisites package: +Prequisites packages: * Go (Go Programming Language) +* Swag (Go Annotations Converter to Swagger Documentation) +* GoReleaser (Go Automated Binaries Build) * Make (Automated Execution using Makefile) -Optional package: -* GoReleaser (Go Automated Binaries Build) +Optional packages: * Docker (Application Containerization) -### Installing +### Deployment + +#### **Using Container** + +1) Install Docker CE based on the [manual documentation](https://docs.docker.com/desktop/) + +2) Run the following command on your Terminal or PowerShell +```sh +docker run -d \ + -p 3000:3000 \ + --name go-whatsapp-multidevice \ + --rm dimaskiddo/go-whatsapp-multidevice-rest:latest +``` + +3) Now it should be accessible in your machine by accessing `localhost:3000/api/v1/whatsapp` or `127.0.0.1:3000/api/v1/whatsapp` + +4) Try to use integrated API docs that accesible in `localhost:3000/api/v1/whatsapp/docs/` or `127.0.0.1:3000/api/v1/whatsapp/docs/` + +#### **Using Pre-Build Binaries** + +1) Download Pre-Build Binaries from the [release page](https://github.com/dimaskiddo/go-whatsapp-multidevice-rest/releases) -Below is the instructions to make this codebase running: -* Create a Go Workspace directory and export it as the extended GOPATH directory +2) Extract the zipped file + +3) Copy the `.env.default` file as `.env` file + +4) Run the pre-build binary +```sh +# MacOS / Linux +chmod 755 go-whatsapp-multidevice-rest +./go-whatsapp-multidevice-rest + +# Windows +# You can double click it or using PowerShell +.\go-whatsapp-multidevice-rest.exe ``` + +5) Now it should be accessible in your machine by accessing `localhost:3000/api/v1/whatsapp` or `127.0.0.1:3000/api/v1/whatsapp` + +6) Try to use integrated API docs that accesible in `localhost:3000/api/v1/whatsapp/docs/` or `127.0.0.1:3000/api/v1/whatsapp/docs/` + +#### **Build From Source** + +Below is the instructions to make this source code running: + +1) Create a Go Workspace directory and export it as the extended GOPATH directory +```sh cd export GOPATH=$GOPATH:"`pwd`" ``` -* Under the Go Workspace directory create a source directory -``` + +2) Under the Go Workspace directory create a source directory +```sh mkdir -p src/github.com/dimaskiddo/go-whatsapp-multidevice-rest ``` -* Move to the created directory and pull codebase -``` + +3) Move to the created directory and pull codebase +```sh cd src/github.com/dimaskiddo/go-whatsapp-multidevice-rest git clone -b master https://github.com/dimaskiddo/go-whatsapp-multidevice-rest.git . ``` -* Run following command to pull dependecies package -``` + +4) Run following command to pull vendor packages +```sh make vendor ``` -* Until this step you already can run this code by using this command -``` + +5) Link or copy environment variables file +```sh ln -sf .env.development .env -make run +# - OR - +cp .env.development .env ``` -## Running The Tests - -Currently the test is not ready yet :) - -## Deployment +6) Until this step you already can run this code by using this command +```sh +make run +``` -To build this code to binaries for distribution purposes you can run following command: +7) *(Optional)* Use following command to build this code into binary spesific platform +```sh +make build ``` + +8) *(Optional)* To make mass binaries distribution you can use following command +```sh make release ``` -The build result will shown in build directory + +9) Now it should be accessible in your machine by accessing `localhost:3000/api/v1/whatsapp` or `127.0.0.1:3000/api/v1/whatsapp` + +10) Try to use integrated API docs that accesible in `localhost:3000/api/v1/whatsapp/docs/` or `127.0.0.1:3000/api/v1/whatsapp/docs/` ## API Access -You can access any endpoint under **BASE_URL** environment variable which by default located at *.env* file. +You can access any endpoint under **HTTP_BASE_URL** environment variable which by default located at *.env* file. + +Integrated API Documentation can be accessed in `/docs/` or by default it's in `localhost:3000/api/v1/whatsapp/docs/` or `127.0.0.1:3000/api/v1/whatsapp/docs/` -Integrated API Documentation can be accessed in **BASE_URL**/docs/index.html or by default it's in `127.0.0.1:3000/api/v1/whatsapp/docs/index.html` +## Running The Tests + +Currently the test is not ready yet :) ## Built With * [Go](https://golang.org/) - Go Programming Languange +* [Swag](https://github.com/swaggo/swag) - Go Annotations Converter to Swagger Documentation * [GoReleaser](https://github.com/goreleaser/goreleaser) - Go Automated Binaries Build * [Make](https://www.gnu.org/software/make/) - GNU Make Automated Execution * [Docker](https://www.docker.com/) - Application Containerization diff --git a/pkg/whatsapp/whatsapp.go b/pkg/whatsapp/whatsapp.go index 3e6cf88..60e9014 100644 --- a/pkg/whatsapp/whatsapp.go +++ b/pkg/whatsapp/whatsapp.go @@ -8,8 +8,9 @@ import ( "fmt" "strings" - qrCode "github.com/skip2/go-qrcode" "github.com/sunshineplan/imgconv" + + qrCode "github.com/skip2/go-qrcode" "google.golang.org/protobuf/proto" "go.mau.fi/whatsmeow"