Skip to content

MandelV/GoMorse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoMorse

Go

Go library that enable to Encode/Decode Morse

Installation

import (
 "github.com/MandelV/GoMorse"
)

Usage

There are some methodes to Encode message to morse and Decode morse to plaintext or get the letter of a given code and code for given letter

To Encode

func Encode(message *string) (morse *string, err error)

Encode take a pointer of the message you want to encode

if Encode succeed : 
return *morse, nil
else :
return nil, err

To Decode

func Decode(morse *string) (message *string, err error)

Decode take a pointer of the morse you want to decode

if Decode succeed : 
return *message, nil
else :
return nil, err

Get Letter of given morse code

func GetLetter(morse string) (letter string, err error)

Get the letter against its morse code

if GetLetter succeed : 
return "", nil
else :
return nil, err

Get Code of given letter

func GetCode(letter string) (code string, err error)

Get the morse code against its letter

if GetCode succeed : 
return "", nil
else :
return nil, err

Overview

Internally the package contains the morse language as Binary Tree :

//Tree represents the morse language
type Tree struct {
	Groot *Node
}

The tree contains nodes, each node represent a letter

//Node represent a letter in Tree
type Node struct {
	Dot    *Node
	Dash   *Node
	Letter string
}

To get the code of a letter you have to browse through the binary tree if the path goes left its a dot (.) otherwise its a dash (-)

Here a representation of the binary tree :

img

TO-DO

About

Go library to Encode / Decode Morse

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages