Skip to content

Commit cfaf283

Browse files
committed
add function eg
1 parent ca59928 commit cfaf283

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

codes/ch2_functions/.gitkeep

Whitespace-only changes.

codes/ch2_functions/function.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package main
2+
3+
import "fmt"
4+
5+
/**
6+
* User defined type Profile act as struct type
7+
*/
8+
type Profile struct {
9+
name string
10+
username string
11+
message string
12+
}
13+
14+
/**
15+
* Define a Greeting function;
16+
*/
17+
func Greeting(github Profile) {
18+
fmt.Println("Name: ", github.name)
19+
fmt.Println("Username: ", github.username)
20+
fmt.Println("Message: ", github.message)
21+
}
22+
23+
func main() {
24+
25+
var github = Profile{"Ashwin Hegde", "hegdeashwin", "Welcome to Go world!"}
26+
27+
/**
28+
* Call the function and pass the data to the function
29+
*/
30+
Greeting(github)
31+
}

0 commit comments

Comments
 (0)