Skip to content

Instantly share code, notes, and snippets.

@hasinhayder
Last active May 20, 2020 19:16
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hasinhayder/2fdbaa4a7f75bc4172839c2e38797905 to your computer and use it in GitHub Desktop.
Save hasinhayder/2fdbaa4a7f75bc4172839c2e38797905 to your computer and use it in GitHub Desktop.
converts a string to NATO phonetic alphabet equivalents
/* Charlie Foxtrot - If You Know What It Means ;) */
package main
import (
"fmt"
"strings"
"bufio"
"os"
)
func main() {
chars := map[rune]string{
' ':"[space]",
'a':"Alpha",
'b':"Bravo",
'c':"Charlie",
'd':"Delta",
'e':"Echo",
'f':"Foxtrot",
'g':"Golf",
'h':"Hotel",
'i':"India",
'j':"Juliett",
'k':"Kilo",
'l':"Lima",
'm':"Mike",
'n':"November",
'o':"Oscar",
'p':"Peru",
'q':"Quebec",
'r':"Romeo",
's':"Sierra",
't':"Tango",
'u':"Uniform",
'v':"Victor",
'w':"Whiskey",
'x':"Xray",
'y':"Yankee",
'z':"Zulu",
'1':"One",
'2':"Two",
'3':"Three",
'4':"Four",
'5':"Five",
'6':"Six",
'7':"Seven",
'8':"Eight",
'9':"Nine",
'0':"Zero",
}
userText := getUserText("Say Something: ")
fmt.Println()
for _, char := range userText {
fmt.Print(chars[char], " ")
}
fmt.Println("\n\nBye Bye \n")
}
func getUserText(label string) string {
fmt.Print(label)
reader := bufio.NewReader(os.Stdin)
text, _ := reader.ReadString('\n')
return strings.ToLower(text)
}
@m4mohaiman
Copy link

<3 Awesome !!

@monirz
Copy link

monirz commented Oct 7, 2016

Cool !

@RayhanArif
Copy link

nifty coding. Go ahead bro.

@raselsay
Copy link

raselsay commented Oct 7, 2016

Awesome boss !

@ShiponKarmakar
Copy link

Awesome bro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment