-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethods01.go
More file actions
43 lines (34 loc) · 813 Bytes
/
methods01.go
File metadata and controls
43 lines (34 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* Alta3 Research | RZFeeser
Methods - defining */
// Go program to illustrate the
// method with struct type receiver
package main
import "fmt"
// Author structure
type author struct {
name string
branch string
books int
salary int
}
// Method with a receiver
// of author type
func (a author) show() {
fmt.Println("Author's Name: ", a.name)
fmt.Println("Branch Name: ", a.branch)
fmt.Println("Published articles: ", a.books)
fmt.Println("Salary: ", a.salary)
}
// Main function
func main() {
// Initializing the values
// of the author structure
res := author{
name: "RZFeeser",
branch: "Pennsylvania",
books: 14,
salary: 34000,
}
// Calling the method
res.show()
}