"Go isIP()"의 두 판 사이의 차이

잔글 (봇: Go 패키지 net을(를) Go net 패키지(으)로 분류 대체함)
 
31번째 줄: 31번째 줄:
* [[함수 is_ip()]]
* [[함수 is_ip()]]


[[분류: Go]]
[[분류:Go]]
[[분류: Go 패키지 net]]
[[분류:Go net 패키지]]

2023년 5월 27일 (토) 20:37 기준 최신판

1 개요[ | ]

Go isIP()
Go validateIP()
package main

import (
	"fmt"
	"net"
)

func isIP(ip string) bool {
	return net.ParseIP(ip) != nil
}

func main() {
	// true
	fmt.Println(isIP("10.40.210.253"))
	fmt.Println(isIP("2001:0db8:85a3:0000:0000:8a2e:0370:7334"))

	// false
	fmt.Println(isIP("example.com"))
	fmt.Println(isIP("1000.40.210.253"))
	fmt.Println(isIP("2001:0db8:85a3:0000:0000:8a2e:0370:7334:3445"))
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}