in

Go – Reversing a String

Go Basics

As a little example of basic Golang, I wrote a little app that takes user input and reverses the word as output:

package main

import "fmt"

var userInput string

func main() {
   reverseWord()
}

func reverseWord() {

   fmt.Println("Input a word> ")
   fmt.Scan(&userInput)
   var word_length int = len(userInput)
   for i := word_length; i > 0; i-- {
      fmt.Print(userInput[(i - 1):i])
   }
}


What do you think?

0 points
Upvote Downvote

Total votes: 0

Upvotes: 0

Upvotes percentage: 0.000000%

Downvotes: 0

Downvotes percentage: 0.000000%

Written by Admin

I work for a Telecom company writing and testing software. My passion for writing code is expressed through this blog. It's my hope that it gives hope to any and all who are self-taught.

Heart Rate Tracking

Go – Variadic Functions