You create new variables inside your if-scopes called year, month, and day:
year, err := strconv.Atoi(s[0])
The :=
is the problem here. At the beginning add a var err error
to your code and remove the colon from your function calls:
var year, month, day int
var err error
year = -1
month = -1
day = -1
// ...
year, err = strconv.Atoi(s[0])
// ...
I believe this should fix your problem. Right now you are creating year, month, and day in the if-scope and never use them (inside the scope).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…