M README.md => README.md +8 -7
@@ 4,13 4,14 @@ This repository contains the code I've written throughout reading the "Introduci
The chapters are organized as follows:
-- Chapter 1: Getting Started
-- Chapter 2: Types
-- Chapter 3: Variables
-- Chapter 4: Control Structures
-- Chapter 5: Arrays, Slices and Maps.
-- Chapter 6: Functions
-- Chapter 7: Structs and Interfaces
+- Chapter 01: Getting Started
+- Chapter 02: Types
+- Chapter 03: Variables
+- Chapter 04: Control Structures
+- Chapter 05: Arrays, Slices and Maps.
+- Chapter 06: Functions
+- Chapter 07: Structs and Interfaces
+- Chapter 08: Packages
The `src/extracurricular` folder contains code examples which explore the language behavior, but don't follow the book. It contains the curiosities I stumbled upon during the learning journey.
A src/chapter8/01-strings_01.go => src/chapter8/01-strings_01.go +22 -0
@@ 0,0 1,22 @@
+package main
+
+import (
+ "fmt"
+ "strings"
+)
+
+// This file contains some Strings package functions to showcase what Go can do.
+func main() {
+ // Let's start with strings.Contains
+ // Contains(str, substr string) bool
+ fmt.Println(strings.Contains("test", "es")) // Shall return true.
+
+ // Count(str, substr string) int
+ fmt.Println(strings.Count("test", "t")) // Shall return 2.
+
+ // HasPrefix(str, prefix string) bool.
+ fmt.Println(strings.HasPrefix("test", "te")) // Shall return true.
+
+ // HasSuffix(str, suffix string) bool.
+ fmt.Println(strings.HasSuffix("test", "st")) // Shall return true.
+}