diff --git a/go.mod b/go.mod index 5c54ed3..78e22c0 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,11 @@ module github.com/RedHatOfficial/GoCourse -go 1.17 +go 1.23.0 + +toolchain go1.23.5 + +require ( + github.com/yuin/goldmark v1.4.13 // indirect + golang.org/x/net v0.43.0 // indirect + golang.org/x/tools v0.36.0 // indirect +) diff --git a/go.sum b/go.sum index e69de29..0c46342 100644 --- a/go.sum +++ b/go.sum @@ -0,0 +1,6 @@ +github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= +golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= +golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg= +golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s= diff --git a/go_primer.slide b/go_primer.slide index 53f23e9..85f3884 100644 --- a/go_primer.slide +++ b/go_primer.slide @@ -138,14 +138,14 @@ Red Hat, Inc. - pass to functions as value or via pointer (by reference) * Structs and dot operator -.play lesson2/11_struct.go +.play lesson2/12_struct.go * Comparison of whole structs is possible! - `==` and `!=` operators -.play lesson2/14_struct_comparison.go /^func main/,/^}/ +.play lesson2/15_struct_comparison.go /^func main/,/^}/ * Comparison of whole structs is possible! (cont.) -.play lesson2/14_struct_comparison.go /^func main/,/^}/ +.play lesson2/15_struct_comparison.go /^func main/,/^}/ * Arrays - basic data type in the Go programming language @@ -158,7 +158,7 @@ Red Hat, Inc. * Array copy - unlike slices, arrays can be copied -.play lesson2/17_array_copy.go +.play lesson2/18_array_copy.go * Slices - proper data type in the Go programming language @@ -174,7 +174,7 @@ Red Hat, Inc. * Usage of slices -.play lesson2/21_slice_append.go +.play lesson2/22_slice_append.go @@ -184,7 +184,7 @@ Red Hat, Inc. - but the slice does not contain any data, just a pointer to array element - so any modify in slice element is reflected in an array as well -.play lesson2/19_slice_copy.go /package main/,/cont// +.play lesson2/20_slice_copy.go /package main/,/cont// * Pointers - always points to an element of some type @@ -198,7 +198,7 @@ Red Hat, Inc. * Basic usage of pointers - please note the usage of `*p_i++` -.play lesson2/22_pointer_to_int.go +.play lesson2/23_pointer_to_int.go * Maps - a.k.a. associative array or hash diff --git a/lesson2.slide b/lesson2.slide index c158739..ef86f1b 100644 --- a/lesson2.slide +++ b/lesson2.slide @@ -194,7 +194,7 @@ Outline: * Defer and existing app -.play lesson2/on_finish.go +.play lesson2/11_on_finish.go @@ -214,7 +214,7 @@ Outline: * Structs and dot operator -.play lesson2/11_struct.go +.play lesson2/12_struct.go @@ -226,7 +226,7 @@ Outline: * Initialization of struct members (cont.) -.play lesson2/12_struct_init.go +.play lesson2/13_struct_init.go @@ -238,30 +238,30 @@ Outline: * Better (more explicit) initialization of struct members (cont.) -.play lesson2/13_better_struct_init.go +.play lesson2/14_better_struct_init.go * Comparison of whole structs is possible! - `==` and `!=` operators -.play lesson2/14_struct_comparison.go /^func main/,/^}/ +.play lesson2/15_struct_comparison.go /^func main/,/^}/ * Comparison of whole structs is possible! (cont.) -.play lesson2/14_struct_comparison.go /^func main/,/^}/ +.play lesson2/15_struct_comparison.go /^func main/,/^}/ * Passing structs as values into functions - by value - by reference (via pointer) -.play lesson2/15_print_user.go /package main/,/^func main// +.play lesson2/16_print_user.go /package main/,/^func main// * Passing structs as values into functions (cont.) -.play lesson2/15_print_user.go /^func main/,/^}/ +.play lesson2/16_print_user.go /^func main/,/^}/ * Struct embedding @@ -292,18 +292,18 @@ Outline: * Basic operations with arrays -.play lesson2/16_arrays.go +.play lesson2/17_arrays.go * Matrix (two dimensional array) -.play lesson2/16B_arrays.go +.play lesson2/17B_arrays.go * Array copy - unlike slices, arrays can be copied -.play lesson2/17_array_copy.go +.play lesson2/18_array_copy.go @@ -323,13 +323,13 @@ Outline: * Usage of slices -.play lesson2/18_slices.go /package main/,/cont// +.play lesson2/19_slices.go /package main/,/cont// * Usage of slices (cont.) -.play lesson2/18_slices.go /cont/,/^}// +.play lesson2/19_slices.go /cont/,/^}// @@ -339,7 +339,7 @@ Outline: - but the slice does not contain any data, just a pointer to array element - so any modify in slice element is reflected in an array as well -.play lesson2/19_slice_copy.go /package main/,/cont// +.play lesson2/20_slice_copy.go /package main/,/cont// @@ -347,25 +347,25 @@ Outline: - modify array elements - then modify the same elements, but via slice -.play lesson2/19_slice_copy.go /cont/,/^}// +.play lesson2/20_slice_copy.go /cont/,/^}// * Slice from slice - "slicing" of another slice is possible -.play lesson2/20_slice_from_slice.go /package main/,/cont// +.play lesson2/21_slice_from_slice.go /package main/,/cont// * Slice from slice (cont.) -.play lesson2/20_slice_from_slice.go /cont/,/^}// +.play lesson2/21_slice_from_slice.go /cont/,/^}// * Append function - the function `append` returns a new slice - the capacity of new slice can be increased (realloc magic inside!) -.play lesson2/21_slice_append.go +.play lesson2/22_slice_append.go @@ -383,49 +383,49 @@ Outline: * Basic usage of pointers - please note the usage of `*p_i++` -.play lesson2/22_pointer_to_int.go +.play lesson2/23_pointer_to_int.go * Pointer to structure -.play lesson2/23_pointer_to_struct.go /package main/,/func main// +.play lesson2/24_pointer_to_struct.go /package main/,/func main// * Pointer to structure (cont.) - please note the possibility to write `p_u.id` instead of `(*p_u).id` -.play lesson2/23_pointer_to_struct.go /func main/,/^}// +.play lesson2/24_pointer_to_struct.go /func main/,/^}// * Pointer to structure item/member -.play lesson2/24_pointer_to_struct_item.go /package main/,/func main// +.play lesson2/26_pointer_to_struct_item.go /package main/,/func main// * Pointer to structure item/member (cont.) -.play lesson2/24_pointer_to_struct_item.go /func main/,/^}// +.play lesson2/26_pointer_to_struct_item.go /func main/,/^}// * Pointer to array item -.play lesson2/25_pointer_to_array.go /package main/,/cont// +.play lesson2/26_pointer_to_array.go /package main/,/cont// * Pointer to array item (cont.) -.play lesson2/25_pointer_to_array.go /cont/,/^}// +.play lesson2/26_pointer_to_array.go /cont/,/^}// * Return pointer to local variable from C function -.code lesson2/25_B_return_pointer.c +.code lesson2/26_B_return_pointer.c * Return pointer to local variable from Go function -.play lesson2/25_B_return_pointer.go +.play lesson2/26_B_return_pointer.go @@ -461,7 +461,7 @@ Outline: * Uninitialized map ("nil map") -.play lesson2/26_uninitialized_map.go +.play lesson2/27_uninitialized_map.go @@ -471,27 +471,27 @@ Outline: * Empty map (int -> string) -.play lesson2/27_initialized_map.go +.play lesson2/28_initialized_map.go * Empty map (string -> int) -.play lesson2/27_B_initialized_map.go +.play lesson2/28_B_initialized_map.go * Empty map (shorter idiom) -.play lesson2/28_initialized_map.go +.play lesson2/29_initialized_map.go * Maps and struct -.play lesson2/29_map_and_struct.go /^package main/,/^func main/ +.play lesson2/30_map_and_struct.go /^package main/,/^func main/ * Maps and struct (cont.) -.play lesson2/29_map_and_struct.go /^func main/,/^}/ +.play lesson2/30_map_and_struct.go /^func main/,/^}/ diff --git a/lesson2/on_finish.go b/lesson2/11_on_finish.go similarity index 100% rename from lesson2/on_finish.go rename to lesson2/11_on_finish.go diff --git a/lesson2/11_struct.go b/lesson2/12_struct.go similarity index 100% rename from lesson2/11_struct.go rename to lesson2/12_struct.go diff --git a/lesson2/12_struct_init.go b/lesson2/13_struct_init.go similarity index 100% rename from lesson2/12_struct_init.go rename to lesson2/13_struct_init.go diff --git a/lesson2/13_better_struct_init.go b/lesson2/14_better_struct_init.go similarity index 100% rename from lesson2/13_better_struct_init.go rename to lesson2/14_better_struct_init.go diff --git a/lesson2/14_struct_comparison.go b/lesson2/15_struct_comparison.go similarity index 100% rename from lesson2/14_struct_comparison.go rename to lesson2/15_struct_comparison.go diff --git a/lesson2/15_print_user.go b/lesson2/16_print_user.go similarity index 100% rename from lesson2/15_print_user.go rename to lesson2/16_print_user.go diff --git a/lesson2/16B_arrays.go b/lesson2/17B_arrays.go similarity index 100% rename from lesson2/16B_arrays.go rename to lesson2/17B_arrays.go diff --git a/lesson2/16_arrays.go b/lesson2/17_arrays.go similarity index 100% rename from lesson2/16_arrays.go rename to lesson2/17_arrays.go diff --git a/lesson2/17_array_copy.go b/lesson2/18_array_copy.go similarity index 100% rename from lesson2/17_array_copy.go rename to lesson2/18_array_copy.go diff --git a/lesson2/18_slices.go b/lesson2/19_slices.go similarity index 100% rename from lesson2/18_slices.go rename to lesson2/19_slices.go diff --git a/lesson2/19_slice_copy.go b/lesson2/20_slice_copy.go similarity index 100% rename from lesson2/19_slice_copy.go rename to lesson2/20_slice_copy.go diff --git a/lesson2/20_slice_from_slice.go b/lesson2/21_slice_from_slice.go similarity index 100% rename from lesson2/20_slice_from_slice.go rename to lesson2/21_slice_from_slice.go diff --git a/lesson2/21_slice_append.go b/lesson2/22_slice_append.go similarity index 100% rename from lesson2/21_slice_append.go rename to lesson2/22_slice_append.go diff --git a/lesson2/22_pointer_to_int.go b/lesson2/23_pointer_to_int.go similarity index 100% rename from lesson2/22_pointer_to_int.go rename to lesson2/23_pointer_to_int.go diff --git a/lesson2/23_pointer_to_struct.go b/lesson2/24_pointer_to_struct.go similarity index 100% rename from lesson2/23_pointer_to_struct.go rename to lesson2/24_pointer_to_struct.go diff --git a/lesson2/25_B_return_pointer.c b/lesson2/26_B_return_pointer.c similarity index 100% rename from lesson2/25_B_return_pointer.c rename to lesson2/26_B_return_pointer.c diff --git a/lesson2/25_B_return_pointer.go b/lesson2/26_B_return_pointer.go similarity index 100% rename from lesson2/25_B_return_pointer.go rename to lesson2/26_B_return_pointer.go diff --git a/lesson2/25_pointer_to_array.go b/lesson2/26_pointer_to_array.go similarity index 100% rename from lesson2/25_pointer_to_array.go rename to lesson2/26_pointer_to_array.go diff --git a/lesson2/24_pointer_to_struct_item.go b/lesson2/26_pointer_to_struct_item.go similarity index 100% rename from lesson2/24_pointer_to_struct_item.go rename to lesson2/26_pointer_to_struct_item.go diff --git a/lesson2/26_uninitialized_map.go b/lesson2/27_uninitialized_map.go similarity index 100% rename from lesson2/26_uninitialized_map.go rename to lesson2/27_uninitialized_map.go diff --git a/lesson2/27_B_initialized_map.go b/lesson2/28_B_initialized_map.go similarity index 100% rename from lesson2/27_B_initialized_map.go rename to lesson2/28_B_initialized_map.go diff --git a/lesson2/28_initialized_map.go b/lesson2/28_initialized_map.go index 2b7d975..8ae3c87 100644 --- a/lesson2/28_initialized_map.go +++ b/lesson2/28_initialized_map.go @@ -3,7 +3,7 @@ package main import "fmt" func main() { - m1 := make(map[int]string) + var m1 map[int]string = make(map[int]string) fmt.Println(m1) m1[1] = "one" diff --git a/lesson2/27_initialized_map.go b/lesson2/29_initialized_map.go similarity index 75% rename from lesson2/27_initialized_map.go rename to lesson2/29_initialized_map.go index 8ae3c87..2b7d975 100644 --- a/lesson2/27_initialized_map.go +++ b/lesson2/29_initialized_map.go @@ -3,7 +3,7 @@ package main import "fmt" func main() { - var m1 map[int]string = make(map[int]string) + m1 := make(map[int]string) fmt.Println(m1) m1[1] = "one" diff --git a/lesson2/29_map_and_struct.go b/lesson2/30_map_and_struct.go similarity index 100% rename from lesson2/29_map_and_struct.go rename to lesson2/30_map_and_struct.go