Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@m4mohaiman m4mohaiman commented Oct 6, 2016

<3 Awesome !!

@monirz

This comment has been minimized.

Copy link

@monirz monirz commented Oct 7, 2016

Cool !

@RayhanArif

This comment has been minimized.

Copy link

@RayhanArif RayhanArif commented Oct 7, 2016

nifty coding. Go ahead bro.

@raselsay

This comment has been minimized.

Copy link

@raselsay raselsay commented Oct 7, 2016

Awesome boss !

@ShiponKarmakar

This comment has been minimized.

Copy link

@ShiponKarmakar ShiponKarmakar commented Nov 22, 2016

Awesome bro

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