File tree 4 files changed +45
-1
lines changed
4 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 8
8
* [ map] ( https://github.com/code4mk/golang-basic/tree/main/map )
9
9
* [ function] ( https://github.com/code4mk/golang-basic/tree/main/function )
10
10
* [ method] ( https://github.com/code4mk/golang-basic/tree/main/method )
11
- * [ pointer] ( https://github.com/code4mk/golang-basic/tree/main/ponter )
11
+ * [ pointer] ( https://github.com/code4mk/golang-basic/tree/main/pointer )
12
12
* [ struct] ( https://github.com/code4mk/golang-basic/tree/main/struct )
13
13
* [ oop (inheritance,interface,polymorphism)] ( https://github.com/code4mk/golang-basic/tree/main/oop )
14
14
Original file line number Diff line number Diff line change
1
+ package employee
2
+
3
+ import (
4
+ "fmt"
5
+ )
6
+
7
+ type Employee struct {
8
+ FirstName string
9
+ Age int
10
+ Phone string
11
+ }
12
+
13
+ func New (FirstName string , Age int , Phone string ) Employee {
14
+ e := Employee {
15
+ FirstName , Age , Phone ,
16
+ }
17
+ return e
18
+ }
19
+
20
+ func (e Employee ) Info () {
21
+ fmt .Println (e )
22
+ }
Original file line number Diff line number Diff line change
1
+ module oop
2
+
3
+ go 1.16
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import "oop/employee"
4
+
5
+ func main () {
6
+ e := employee.Employee {
7
+ FirstName : "Sam" ,
8
+ Age : 21 ,
9
+ Phone : "01751255157" ,
10
+ }
11
+ e .Info ()
12
+
13
+ // var p employee.Employee
14
+ // p.Info()
15
+
16
+ // constructor
17
+ var q = employee .New ("kamal" , 21 , "01851255158" )
18
+ q .Info ()
19
+ }
You can’t perform that action at this time.
0 commit comments