code: func isIPv4(ip string) bool {
  	// acc: keep the decimal value of each segment under check, which should between 0 and 255 for valid IPv4 address.
  	// pd: sentinel for '.'
  	dots, acc, pd := 0, 0, true
  	for _, c := range ip {
  		switch {
  		case '0' <= c && c <= '9':
  			acc = acc*10 + int(c-'0')
  			pd = false
  		case c == '.':
  			dots++
  			if dots > 3 || acc > 255 || pd {
  				return false
  			}
  			acc, pd = 0, true
  		default:
  			return false
  		}
  	}
  	if dots != 3 || acc > 255 || pd {
  		return false
  	}
  	return true
  }
docs: // isIPv4 checks IPv4 address which satisfying the format A.B.C.D(0<=A/B/C/D<=255).
  // Mapped IPv6 address like '::ffff:1.2.3.4' would return false.