Giter VIP home page Giter VIP logo

morse's Introduction

Morse

Introduction

This is a small utility which can be used to convert text into morse code and vice versa.

This utility was built as my first usage of the Go programming language and was an opportunity to understand some of its key concepts and commonly used practices such as:

  • Range
  • Slices
  • Maps
  • Function passing
  • Command line parameter parsing
  • Regular expressions and capture groups

I wanted to do all this by only using what is available in the Go standard library even though there are no doubt numerous other packages available. Its also worth pointing out that a 3rd party library gSpera/morse already exists to do text/morse transformations - however - by building the utility it was an opportunity to understand some of Go's range, slice and map operations.

Tests

You can run the associated tests with:

go test morse

Usage

You can run go run main.go -h to get help on how to use the utility

Convert Text To Morse Code

Run

go run main.go morse --text "Hello World"

Which will return:

.... . .-.. .-.. --- / .-- --- .-. .-.. -..

Convert Morse Code To Text

Run go run main.go text --morse ".... . .-.. .-.. --- / .-- --- .-. .-.. -.."

Which will return:

HELLO WORLD

Observations

  • The Go regex library does not support named capture groups at present and is discussed under #64108. Only a single repeating capture group was required for this so not being able to name it was not a serious issue.
  • The flag library is a little clunky - especially for sub-command processing.

Tools used

morse's People

Contributors

iang avatar

Watchers

 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.