-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
51 lines (41 loc) · 1.03 KB
/
main.go
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
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
"github.com/erankitcs/golang_learning/customdatatypes/datatypes4/organisation"
)
type Name struct {
First string
Last string
Middle []string
}
type OtherName struct {
First string
Last string
}
func (n Name) Equals(otherName Name) bool {
return n.First == otherName.First && n.Last == otherName.Last && len(n.Middle) == len(otherName.Middle)
}
func main() {
fmt.Println("Custom Type Demo 4")
p := organisation.NewPerson("Ankit", "Singh", organisation.NewEuropeanUnionIdentifier("123-45-33", "UK"))
err := p.SetTwitterHandler("@ankit63")
fmt.Printf("%T\n", organisation.TwitterHandler("test"))
if err != nil {
fmt.Printf("An error occurred while setting handler %s", err.Error())
}
name1 := Name{
First: "",
Last: "",
}
if name1.Equals(Name{}) {
println("We match")
}
p.First = "NewName"
println(p.First)
println(p.Name.First)
fmt.Println(p.TwitterHandler())
fmt.Println(p.TwitterHandler().RedirectURL())
fmt.Println(p.FullName())
fmt.Println(p.ID())
println(p.Country())
}