开发者

Cast from renamed type in google go

开发者 https://www.devze.com 2023-03-09 16:50 出处:网络
I\'m trying to write suitable method of converting appengine/datastore.Time type to string. This type is declared as type Time int64

I'm trying to write suitable method of converting appengine/datastore.Time type to string. This type is declared as type Time int64 But when i'm trying to use it as int64 value:

localTime := time.SecondsToLocalTime(t/1000)

I'm receiving error message

cannot use t / 1000 (type datastore.Time) as type int64 in function argument

Assignment from int64 to Time typed 开发者_JS百科variable is successfull, but how can i cast it back?


do it like

time.SecondsToLocalTime(int64(t)/1000)

See more in the documentation about Conversions

0

精彩评论

暂无评论...
验证码 换一张
取 消