push all exercices
This commit is contained in:
BIN
ch6/1/ch6_1.exe
Normal file
BIN
ch6/1/ch6_1.exe
Normal file
Binary file not shown.
22
ch6/1/ch6_1.go
Normal file
22
ch6/1/ch6_1.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Person struct {
|
||||
FirstName string
|
||||
LastName string
|
||||
Age int
|
||||
}
|
||||
|
||||
func MakePerson(firstName, lastName string, age int) Person {
|
||||
return Person{firstName, lastName, age}
|
||||
}
|
||||
|
||||
func MakePersonPointer(firstName, lastName string, age int) *Person {
|
||||
return &Person{firstName, lastName, age}
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println(MakePerson("Ivan", "Ivanov", 21))
|
||||
fmt.Println(*MakePersonPointer("Peter", "Petrov", 22))
|
||||
}
|
||||
3
ch6/1/go.mod
Normal file
3
ch6/1/go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module ch6_1
|
||||
|
||||
go 1.25.0
|
||||
Reference in New Issue
Block a user