2024-04-15 08:30:10 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2024-04-15 11:49:18 +02:00
|
|
|
"time"
|
2024-04-15 08:30:10 +02:00
|
|
|
)
|
|
|
|
|
2024-04-15 11:49:18 +02:00
|
|
|
type Person struct {
|
|
|
|
name string
|
|
|
|
country string
|
2024-04-15 08:30:10 +02:00
|
|
|
}
|
|
|
|
|
2024-04-15 11:49:18 +02:00
|
|
|
type yearType int
|
|
|
|
|
|
|
|
func (p Person) Create() (newP *Person) {
|
|
|
|
var newPerson = new(Person)
|
|
|
|
newPerson.name = "John"
|
|
|
|
newPerson.country = "Spain"
|
|
|
|
return newPerson
|
|
|
|
}
|
|
|
|
|
|
|
|
func (y yearType) currentYear() (year yearType) {
|
|
|
|
t := time.Now()
|
|
|
|
ye := t.Year()
|
|
|
|
yea := yearType(ye)
|
|
|
|
return yea
|
2024-04-15 08:30:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2024-04-15 11:49:18 +02:00
|
|
|
p := Person{}
|
|
|
|
var ourYear yearType
|
|
|
|
newP := p.Create()
|
|
|
|
fmt.Printf("Hello, I am %s and live in %s and the current year is %d\n", newP.name, newP.country, ourYear.currentYear())
|
2024-04-15 08:30:10 +02:00
|
|
|
}
|