first name last name and age customer struct
This commit is contained in:
parent
06174644a1
commit
6514c53747
3 changed files with 21 additions and 1 deletions
1
main.go
1
main.go
|
@ -54,4 +54,5 @@ func main() {
|
|||
pointers.Demo2(numbers)
|
||||
fmt.Println("Numbers in Main", numbers[0])
|
||||
structs.Demo1()
|
||||
structs.Demo2()
|
||||
}
|
||||
|
|
|
@ -12,3 +12,4 @@ type product struct {
|
|||
brand string
|
||||
discountRate int
|
||||
}
|
||||
|
||||
|
|
18
structs/demo2.go
Normal file
18
structs/demo2.go
Normal 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()
|
||||
}
|
Loading…
Add table
Reference in a new issue