Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
14 changes: 7 additions & 7 deletions go_primer.slide
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -174,7 +174,7 @@ Red Hat, Inc.

* Usage of slices

.play lesson2/21_slice_append.go
.play lesson2/22_slice_append.go



Expand All @@ -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
Expand All @@ -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
Expand Down
66 changes: 33 additions & 33 deletions lesson2.slide
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Outline:


* Defer and existing app
.play lesson2/on_finish.go
.play lesson2/11_on_finish.go



Expand All @@ -214,7 +214,7 @@ Outline:


* Structs and dot operator
.play lesson2/11_struct.go
.play lesson2/12_struct.go



Expand All @@ -226,7 +226,7 @@ Outline:


* Initialization of struct members (cont.)
.play lesson2/12_struct_init.go
.play lesson2/13_struct_init.go



Expand All @@ -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
Expand Down Expand Up @@ -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



Expand All @@ -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/,/^}//



Expand All @@ -339,33 +339,33 @@ 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//



* Slices and arrays as data source for them (cont.)
- 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



Expand All @@ -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



Expand Down Expand Up @@ -461,7 +461,7 @@ Outline:


* Uninitialized map ("nil map")
.play lesson2/26_uninitialized_map.go
.play lesson2/27_uninitialized_map.go



Expand All @@ -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/,/^}/



Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lesson2/28_initialized_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
File renamed without changes.