← All Exercises

Go String Basics

basicgo~15min

Background

Go strings are UTF-8 encoded byte sequences, requiring rune conversion for proper Unicode character handling.

Problem

Write a Go function that takes a string and returns its byte length, rune count, and reversed version.

Input

A string containing potentially multi-byte Unicode characters.

Output

A struct with byte length, rune count, and reversed string.

Sample tests

Sample 1

Input: "hello"
Expected: {byteLen:5, runeCount:5, reversed:"olleh"}

Your solution

Learning objective

Understand Go string representation, byte vs rune length, and Unicode reversal.