carbon
carbon copied to clipboard
Unable to read language.json file
Hello,
I encountered an issue with the following code:
lange := carbon.NewLanguage()
lange.SetLocale("zh-CN")
car := carbon.SetLanguage(lange)
if car.Error != nil {
log.Printf("Error Info %v\n", car.Error)
return
}
offDutyTime := car.Now().StartOfDay().AddHours(18)
now := car.Now()
diff:= now.DiffInString(offDutyTime)
log.Printf("Diff: %v", diff)
golang version: such as 1.16
1.18.1
carbon version: such as 1.5.0
v2.1.8
time zone: such as Japan
China
I expected to get:
`Diff: 9小时`
But I actually get:
invalid locale file "lang\\zh-CN.json", please make sure the json file exists and is valid
Pic:

Thanks!
Sorry, I haven't tested it on the window platform, I will try to find a window platform device to test.
I had the same problem, windows10, go.1.18.3, carbon: v2.1.8

=== RUN TestWeek a_test.go:15: invalid locale file "lang\zh-CN.json", please make sure the json file exists and is valid
--- FAIL: TestWeek (0.00s)
FAIL
It has been fixed in v1.7.1 or v2.2.1