github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/tests/files/method17b.gno (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/gnolang/gno/_test/time"
     7  )
     8  
     9  type MyTime struct {
    10  	time.Time
    11  	index int
    12  }
    13  
    14  func (m MyTime) Foo() {
    15  	minute := m.Minute()
    16  	fmt.Println("minute:", minute)
    17  }
    18  
    19  func (m *MyTime) Bar() {
    20  	second := m.Second()
    21  	fmt.Println("second:", second)
    22  }
    23  
    24  func main() {
    25  	t := MyTime{}
    26  	t.Time = time.Date(2009, time.November, 10, 23, 4, 5, 0, time.UTC)
    27  	t.Foo()
    28  	t.Bar()
    29  	(&t).Bar()
    30  }
    31  
    32  // Output:
    33  // minute: 1111
    34  // second: 2222
    35  // second: 2222