Go lang | type 비교 (whether string or float64)
페이지 정보
- 작성자:
- 핵탐
- 작성일
- 02.17 14:05
- 조회
- 1,918
- 댓글
- 0
본문
1. 첫번째 방법
[code]
str := 129.29438455
if reflect.TypeOf(str).String() != "string" {
//
}
[/code]
2. 두번째 방법
[code]
a := "34.1718000440"
switch a.(type) {
case float64:
fmt.Println("This is float64")
case string:
fmt.Println("This is string")
default:
fmt.Println("unknown")
}
[/code]
댓글 0개
등록된 댓글이 없습니다.