Sobes.tech
Junior — Middle

Mis vahe on mäluyksusel bait ja andmetüüpi rune vahel programmeerimiskeeles?

sobes.tech AI

Vastus AI-lt

In the Go language, byte (byte) is simply a synonym for the type uint8, which is an 8-bit unsigned integer, commonly used to represent a single byte of data.

Rune (rune) is a data type representing a Unicode code point, and is essentially a synonym for int32. Rune allows storing Unicode characters, including those that require more than one byte in UTF-8.

Example:

var b byte = 65       // ASCII 'A'
var r rune = 'Я'      // Cyrillic letter, Unicode code point
fmt.Println(b)        // 65
fmt.Println(r)        // 1071

Thus, byte is useful for working with raw data and byte slices, while rune is for working with characters and text in Unicode.