Strings & Formatting (Printf, strings Package, Slicing) - Go Tutorial for Beginners #3
6views
004:35
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
Learn how to work with strings and formatting in Go! š
In this lesson, you will learn:
ā
String literals and raw strings
ā
String concatenation with +
ā
Printf format verbs (%s, %d, %f, %v, %T)
ā
The strings package (ToUpper, ToLower, Split, Join)
ā
String indexing and slicing
š Timestamps:
0:00 - Introduction
0:24 - String Basics & Concatenation
1:03 - Printf Formatting
1:42 - strings Package
2:27 - String Indexing & Slicing
3:09 - Recap
3:39 - End
š» Source Code: https://github.com/GoCelesteAI/go_strings
š Code from this lesson:
// String concatenation
greeting := "Hello"
name := "World"
message := greeting + ", " + name + "!"
// Printf formatting
fmt.Printf("Name: %s\n", name)
fmt.Printf("Age: %d years\n", age)
fmt.Printf("Price: $%.2f\n", price)
fmt.Printf("Type: %T, Value: %v\n", age, age)
// strings package
strings.ToUpper("hello") // "HELLO"
strings.TrimSpace(" hi ") // "hi"
strings.Split("a,b,c", ",") // ["a", "b", "c"]
strings.Join(slice, "-") // "a-b-c"
// String slicing
word := "Golang"
word[0] // 'G' (first character)
word[:2] // "Go" (first 2)
word[2:] // "lang" (from index 2)
word[1:5] // "olan" (middle portion)
š Previous: Lesson 2 - Variables & Types
š Next: Lesson 4 - Numbers & Math
#Go #Golang #GoTutorial #LearnGo #Programming #Strings #Printf #Formatting #GoProgramming