go - Undefined Error in Golang -


i have following structure:

/*gotime.go*/ package gotime  type struct {     dnow int     ynow int     mnow time.month } 

and there function like:

/*gotime.go*/ func (n now) daynow() int {     n.dnow = time.now().day()     return n.dnow  } 

i'm getting following error when want call package:

/*main.go*/ package main  import (     "fmt"     "./gotime" )  blah := fmt.println(blah.daynow()) 

i errors:

# command-line-arguments .\main.go:5: imported , not used: "_/c_/users/ali/desktop/test/gotime" .\main.go:10: undefined: 

you can @ of package on github:

link package

how can solve problem?

since now struct, need struct composite literal create value of type.

also since package, need qualified name:

blan := gotime.now{} 

also since modifying it, should / need use pointer receiver:

func (n *now) daynow() int {     n.dnow = time.now().day()     return n.dnow } 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -