Go int月份

Situation:

When I call time functions like Second(), Year() etc., I get a result of tye int. But when I call Month(), I get a result of type Month.

I found the following in the online docs:

type Month int
...
func (m Month) String() string

.. but I don't quite understand it.

Problem:

My code has the following error because m is not an int:

invalid operation: m / time.Month(10) + offset (mismatched types time.Month and int)

Question:

How to get an int from Month()?

Considering:

var m time.Month

m's type underlying type is int, so it can be converted to int:

var i int = int(m) // normally written as 'i := int(m)'

On a side note: The question shows a division 'm / time.Month(10)'. That may be a bug unless you want to compute some dekamonth value ;-)

You have to explicitly convert it to an int:

var m Month = ...
var i int = int(m)

Check this minimal example in the go playground.