Last active
May 20, 2020 19:16
-
-
Save hasinhayder/2fdbaa4a7f75bc4172839c2e38797905 to your computer and use it in GitHub Desktop.
converts a string to NATO phonetic alphabet equivalents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome bro