Go/Strings: Difference between revisions
From charlesreid1
No edit summary |
No edit summary |
||
| Line 3: | Line 3: | ||
The Go blog: strings, bytes, runes, and characters in Go: https://blog.golang.org/strings | The Go blog: strings, bytes, runes, and characters in Go: https://blog.golang.org/strings | ||
==How Strings Work== | |||
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 at that point in time. | 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. | |||
==Slices== | |||
Revision as of 18:16, 12 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.
Slices
Flags
| Go notes on Go
Go/Strings · Go/Arrays · Go/Slices
Go/Lists · Go/Maps · Go/Stacks · Go/Queues
Go/Naming Conventions · Go/Design Patterns
Go/Timing · Go/Profiling · Go/Benchmarking
Go/Tests · Go/Travis CI · Go/Makefiles
our vim + go setup uses custom solarized colors for Golang
|