As a little example of basic Golang, I wrote a little app that takes user input and reverses the word as output:
[pastacode lang=”c” manual=”package%20main%0A%0Aimport%20%22fmt%22%0A%0Avar%20userInput%20string%0A%0Afunc%20main()%20%7B%0A%20%20%20reverseWord()%0A%7D%0A%0Afunc%20reverseWord()%20%7B%0A%0A%20%20%20fmt.Println(%22Input%20a%20word%3E%20%22)%0A%20%20%20fmt.Scan(%26userInput)%0A%20%20%20var%20word_length%20int%20%3D%20len(userInput)%0A%20%20%20for%20i%20%3A%3D%20word_length%3B%20i%20%3E%200%3B%20i–%20%7B%0A%20%20%20%20%20%20fmt.Print(userInput%5B(i%20-%201)%3Ai%5D)%0A%20%20%20%7D%0A%7D” message=”” highlight=”” provider=”manual”/]
Comments are closed