GO int64转int32

 strconv.ParseInt转换后 都是int64 ,设定 strconv.ParseInt(uid, 10, 32)后,还是int64 所以转换为int32

  if userId, err = strconv.ParseInt(uid, 10, 64); err != nil {
      userId = 0
   }
   var roomIdTemp int64
   if roomIdTemp, err = strconv.ParseInt(rid, 10, 64); err != nil {
      roomId = 1
   } else {
      roomId = int32(roomIdTemp)
   }
   fmt.Printf("类型输出userId:%T->%v\n", userId, userId)
   fmt.Printf("类型输出roomId:%T->%v\n", roomId, roomId)

你可能感兴趣的:(go)