From 6514c537472838281b53ed24000721c39fe95ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20G=C3=B6r?= Date: Sat, 20 Jan 2024 18:21:37 +0300 Subject: [PATCH] first name last name and age customer struct --- main.go | 1 + structs/demo1.go | 3 ++- structs/demo2.go | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 structs/demo2.go diff --git a/main.go b/main.go index af5adbe..a95a129 100644 --- a/main.go +++ b/main.go @@ -54,4 +54,5 @@ func main() { pointers.Demo2(numbers) fmt.Println("Numbers in Main", numbers[0]) structs.Demo1() + structs.Demo2() } diff --git a/structs/demo1.go b/structs/demo1.go index 0675115..5ce7ee6 100644 --- a/structs/demo1.go +++ b/structs/demo1.go @@ -11,4 +11,5 @@ type product struct { unitPrice float64 brand string discountRate int -} \ No newline at end of file +} + diff --git a/structs/demo2.go b/structs/demo2.go new file mode 100644 index 0000000..ad3af76 --- /dev/null +++ b/structs/demo2.go @@ -0,0 +1,18 @@ +package structs + +import "fmt" + +type customer struct{ + firstName string + lastName string + age int +} + +func (c customer) save() { + fmt.Println("Has been added : ", c.firstName, c.lastName,c.age) +} + +func Demo2() { + c:= customer{firstName: "Engin", lastName: "Demiroğ", age: 35} + c.save() +} \ No newline at end of file