first name last name and age customer struct

This commit is contained in:
Mert Gör 🇹🇷 2024-01-20 18:21:37 +03:00
parent 06174644a1
commit 6514c53747
Signed by: hwpplayer1
GPG Key ID: 03E547D043AB6C8F
3 changed files with 21 additions and 1 deletions

View File

@ -54,4 +54,5 @@ func main() {
pointers.Demo2(numbers)
fmt.Println("Numbers in Main", numbers[0])
structs.Demo1()
structs.Demo2()
}

View File

@ -12,3 +12,4 @@ type product struct {
brand string
discountRate int
}

18
structs/demo2.go Normal file
View File

@ -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()
}