Differences between revisions 2 and 3
Revision 2 as of 2023-01-08 05:54:12
Size: 1159
Comment:
Revision 3 as of 2023-01-08 06:00:14
Size: 1406
Comment:
Deletions are marked like this. Additions are marked like this.
Line 13: Line 13:
Like other container types, `string` data can be operated on using:

 * element access (`str[0]`) and slice (`str[0:1]`) syntax
 * the built-in `len()` function
 * addition (`+`) and in-place addition (`+=`) operators for concatenation
Line 15: Line 21:
 * in `for i, r := range s`, the `r` is a Unicode rune
 * in `rs := []rune(s)`, `rs` is a string of Unicode runes
 * in `for _, r := range str`, the `r` is a Unicode rune
 * in `rs := []rune(str)`, `rs` is a string of Unicode runes

Go Data Types


String

A string is an immutable container of uint8 bytes.

Like other container types, string data can be operated on using:

  • element access (str[0]) and slice (str[0:1]) syntax

  • the built-in len() function

  • addition (+) and in-place addition (+=) operators for concatenation

They are meant to represent text encoded in UTF-8, but not every byte is guaranteed to be valid Unicode. There are only a few instances where strings are implicitly encoded:

  • in for _, r := range str, the r is a Unicode rune

  • in rs := []rune(str), rs is a string of Unicode runes

In these cases, all invalid Unicode bytes are converted to U+FFFD (the replacement character).


Bool


Numeric Types

  • signed integers: int8, int16, int32, int64, and int

  • unsigned integers: uint8, uint16, uint32, uint64, and uint

  • uintptr

  • floating point numbers: float32 and float64

  • complex numbers: complex64 and complex128

byte is an alias to uint8, and rune is an alias to int32.


Pointer


Struct


Function


Container Types

  • array

  • slice

  • map


Channel


Interface


CategoryRicottone

Go/DataTypes (last edited 2023-01-08 06:00:14 by DominicRicottone)