package main

import "fmt"

func main(){
	
	slice := []string{"hola", "que", "hace"}
	for i, valor := range slice{
		fmt.Println(i, valor)
	}
}
0 hola
1 que
2 hace

Palíndromo

package main

import "fmt"

func isPalindromo(text string) {
	var textReverse string
	for i:= len(text) - 1; i >= 0; i-- {
		textReverse += string(text[i]) // Esto es equivalente a textReverse = textReverse + lo que quiera agregar
	}
	if text == textReverse {
		fmt.Println("Es palíndromo")
	} else {
		fmt.Println("No es palíndromo")
	} 
}

func main(){
	
	isPalindromo("amor a roma")
}
Es palíndromo

El código anterior sirve solo para letras en minúscula, si se ingresa una letra en mayúscula, el código no funciona como se espera.

Reto

Realizar el mismo algoritmo palíndromo pero que funcione correctamente con palabras que contengan mayúscula.

package main

import (
	"fmt"
	"strings"
)

func isPalindromo(text string) {
	var textReverse string
	for i:= len(text) - 1; i >= 0; i-- {
		textReverse += string(text[i]) // Esto es equivalente a textReverse = textReverse + lo que quiera agregar
	}
	if strings.ToLower(text) == strings.ToLower(textReverse) {
		fmt.Println("Es palíndromo")
	} else {
		fmt.Println("No es palíndromo")
	} 
}

func main(){
	isPalindromo("ana")
}

Lecturas recomendadas

strings