From charlesreid1

Line 11: Line 11:
==String Slices==
==String Slices==


See the [[Go/Arrays]] page for notes on how array slices work.
See the [[Go/Slices]] page for notes on how array slices work.


=Flags=
=Flags=


{{GoFlag}}
{{GoFlag}}

Revision as of 02:26, 13 December 2018

Related: Rosalind/Problem 1A

The Go blog: strings, bytes, runes, and characters in Go: https://blog.golang.org/strings

How Strings Work

A string in Go is a read-only slice of bytes. A string can hold arbitrary bytes, it is not required to hold unicode/UTF-8/other format. That means that "characters" are not special types in Go; rather, strings refer to bytes.

Indexing a string does not access characters - it accesses the individual bytes. So, when you store a character value in a string, you are storing the byte representation of that character at that point in time.

String Slices

See the Go/Slices page for notes on how array slices work.

Flags