课程: Go Essentials: Concurrency, Connectivity, and High-Performance Apps

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Strings

Strings

- [Instructor] Strings and go starts with double quotes. Here we have the variable book assigned to a string, "The color of magic." And we are going to use the FMT printer in to print out the book. Let's run it. And we see that we have the color of magic. When we are going to print the len of the book, how many bytes are in the book, we can use the built-in len function. And we have 19 bytes in the book. We can access the first bite with the square brackets and index zero. In the FMT verb, we are going to do percent V for print any go type and percent T to print type of the verb. When we run this one, you're going to say that it is 84, which is the number for the capital B. And it's a U in eight which in go stands for a byte. In go strings are imutable you see the ID is painting this code in red. And if I'll try to run it, I will get a panic. So you cannot assign to a book. So I'll comment this one out. To get…

内容