GithubHelp home page GithubHelp logo

eneskzlcn / morsencoder Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 60 KB

morsencoder is an api that listens for any request to the endpoint "/encode" with a query parameter text like "/encode?text=text to morse code encode", encodes that text and returns it back to the client as string.

Go 94.65% Dockerfile 1.28% Makefile 4.07%
golang unit-testing api-server go-fiber morse-code-translator http-testing test-driven-development docker-image dockerci golangci

morsencoder's Introduction

morsencoder

About Project

morsencoder is an api that listens for any request to the endpoint "/encode" with a query parameter text like "/encode?text=text to morse code encode", encodes that text and returns it back to the client as string.

Letter Separation

morsencoder uses letter separator as one whitespace. Each letter encoded to morse code will be seperated by one whitespace.

Ex: given text "ab" will be encoded as .- -... where .- is the a letter and -... is the b letter in morse code alphabet.

Word Separation

morsencoder uses letter separator as one backslash between two whitespaces(' / '). Each word encoded to morse code will be seperated by one backslash between two whitespaces(' / ').

Ex: given text aa bb will be encoded as .- .- / -... -... where .- is the a letter and -... is the b letter and is the letter separator in morse code alphabet.

How To Build

You can directly use the make command written for build

make build

to build the application.

For docker builds, you can use

make dockerize

to build the image with the name eneskzlcn/morsencoder and with tag "latest". If you build with another name and tag you can configure the dockerize command in Makefile or you can directly execute the following command:

docker build -t <image-name>:<image-tag> .

How To Test

Before you execute the tests, you need to execute the command

make generate-mocks

to generate all necessary mocks for tests.

After mocks generated, you can simply execute

make unit-tests

to run all unit tests, or you can use following command:

go test -v ./...

for run all tests or

go test -v .internal/...

to just run domain tests.

How To Run

If you have go 1.18 installed on your machine, you can simply build the application with command

go build -o bin/morsencoder .cmd/morsencoder

and then run

./bin/morsencoder

or

go run ./cmd/morsencoder/main.go

If you have docker installed on your machine, you can also run application as docker container with the following commands

docker build -t <image-name>:<image-tag> .

to build docker image, and

docker run -p <host-port>:4200 <image-name>:<image-tag>

to run docker image as docker container.

Run Linter

I use golangci-lint default linter. If you have golangci-lint installed on your machine, you can simply use

golangci-lint run

to run linters.

Test Coverage

I use GoLand IDE which provides me to test coverage of my code.

If you use GoLand IDE you can simply go to the ./internal/morsencoder and right click on morsencoder_test package. Then select Run with Coverage from menu which brings you a coverage report that contains your coverage as percentage on chosen package (morsencoder).

I have 100% coverage on the domain files ./internal/morsencoder

Letter Morse Code Key Map

'A': ".-"

'B': "-..."

'C': "-.-."

'D': "-.."

'E': "."

'F': "..-."

'G': "--."

'H': "...."

'I': ".."

'J': ".---"

'K': "-.-"

'L': ".-.."

'M': "--"

'N': "-."

'O': "---"

'P': ".--."

'Q': "--.-"

'R': ".-."

'S': "..."

'T': "-"

'U': "..-"

'V': "...-"

'W': ".--"

'X': "-..-"

'Y': "-.--"

'Z': "--.."

'1': ".----"

'2': "..---"

'3': "...--"

'4': "....-"

'5': "....."

'6': "-...."

'7': "--..."

'8': "---.."

'9': "----."

'0': "-----"

'.': ".-.-.-"

',': "--..--"

'?': "..--.."

'!': "-.-.--"

'-': "-....-"

'/': "-..-."

'@': ".--.-."

'(': "-.--."

')': "-.--.-"

morsencoder's People

Contributors

enesarf avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.