func Delete_exam(UserId int,ExamId string){ //я передаю ExamId строкой и хочу перевести в int log.Println(ExamId ) //отображается число в кавычках , т.е. string тип var Exam_id_int int if Exam_id, err := strconv.Atoi(string(ExamId)); err == nil { fmt.Printf("Exam_id=%d, type: %T\n", Exam_id_int , Exam_id_int ) } //....... }
I am 100% sure that there is a number inside the text, but it falls into the exception, i.e. can not convert. At the same time, if I forcibly set ExamId = "777", here the number is recognized and everything will be ok.
Maybe in ExamId there are some other characters, because of what he does not want to be transferred to an int? I hit my head against the wall, I can't understand