Skip to content

Instantly share code, notes, and snippets.

@nikita8
Last active October 8, 2018 10:18
Show Gist options
  • Save nikita8/e0810f0e431d0bff08aae40c342cc34e to your computer and use it in GitHub Desktop.
Save nikita8/e0810f0e431d0bff08aae40c342cc34e to your computer and use it in GitHub Desktop.
W06::C01 Generate acronym from the input string
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func main() {
reader := bufio.NewReader(os.Stdin)
fmt.Print("Enter input text: ")
testString, _ := reader.ReadString('\n')
testArray := strings.Fields(testString)
var firstLetter string
for _, v := range testArray {
firstLetter += v[:1]
}
firstLetter = strings.ToUpper(firstLetter)
fmt.Println(firstLetter)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment