Golang Strings HD
caleb’s code TAKE THE ENTIRE COURSE https://greatercommons.com/ https://github.com/golang-book/bootcamp-examples todd’s code https://github.com/GoesToEleven/GolangTraining/ course outline https://goo.gl/EIbk7a Learn The Language - Golang Training https://goo.gl/DB1GvG Learn The Language - Great Golang Books https://www.golang-book.com/books/intro (Caleb Doxsey) http://amzn.to/1PmlB1w (Bill Kennedy) http://amzn.to/21nO1Mc (Donovan & Kernighan) http://amzn.to/1PmlKSB (Balbaert) Learn The Language - Quick Code Samples https://gobyexample.com/ Playlist of all videos in training https://goo.gl/WWCh9D Index of Videos https://goo.gl/SDgaEr ASK QUESTIONS & GET HELP https://forum.golangbridge.org/c/getting-help STAY CONNECTED G+ https://goo.gl/kWyztP https://twitter.com/Todd_McLeod https://www.youtube.com/user/toddmcleod NOTES ON THIS VIDEO: ROUNDING NUMBERS; add .5 then take the floor; MATH PACKAGE; STRING is just a series of characters; strings in golang use UTF-8; ASCII is a 7 bit character series; UTF-8 is those same 7 bits, ASCII, which is 128 letters, and for everything else it has multiple bytes; UTF-8 is a multiple byte character encoding; for everything else characters could be two bytes, or three bytes, or four bytes per character; things written in chinese probably will be four bytes per character; golang uses UTF-8 because Rob Pike & Ken Thompson were partially inventors of UTF-8; use DOUBLE QUOTES or BACKTICKS to create STRINGS; backticks can be multiple lines; strings support escape sequences like
for newline or for a tab; you can see the golang spec “string literals” for a description of those escape sequences; we can get the LENGTH of a string by using LEN; this gives us THE NUMBER OF BYTES not the number of characters; (5:00); CONCATENATE strings with +; var str = “Hello world “ + “test”; this doesn’t work: var str = “Hello world “ + 5; this does work: var str = “Hello world “ + “5”; what about this var x int = 5; var str = “Hello world “ + strconv.Itoa(x); STRCONV ITOA; you can also do this: var str = “Hello world “ + fmt.Sprint(x); FMT SPRINT; (9:00); fmt.Sprint converts anything to a string; if you had x float64 and y int --- you could add them together with x + float64(y); conversion (10:00); or like this int(x) + y; ROUNDING again (11:00); math.Floor(x+0.5); or like this: int(x+.05); SLICING strings; var x string = “Hello world”; fmt.Println(x[2]); BYTE is a synonym for UINT8; PANIC (15:30); panic is goes way of dealing with bad errors; panics usually indicate the programmer screwed up; index out of range would be an example of a panic; BOOLEANS; operators: && || !
Похожие видео
Показать еще