Getting Contents from a URL and converting it into string

Hello, i am developing a cpanel based software ( well it’s not the topic )
actually i want to get contents from a url and want to convert that content to string because i tried by general way it’s giving uint8 byet code.
here is the URL :
this url shows our IPv4 Address, i want to read that IPv4 Address in a variable and want to convert that ip to string so that i can use that easily.

actually as i told i am developing a software that requires license and license is based on IP so i want to convert it as string so that i can use that IP easily like showing Your IPv4 Address : fmt.Printf(ip)
if ip == “x.x.x.x” {
else {
fmt.Println(“you’re not allowed”)

hope you’re understood, so please tell me a way how can i read contents from that url and convert that content to a string

Use type net.IP, the canonical form for IP addresses.

package main

import (

func getMyIP() (net.IP, error) {
	resp, err := http.Get("")
	if err != nil {
		return nil, err
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	ip := net.ParseIP(string(bytes.TrimSpace(body)))
	if ip == nil {
		err := errors.New("invalid IP address")
		return nil, err
	return ip, nil

func main() {
	myip, err := getMyIP()
	fmt.Println(myip, err)
	if err != nil {

	fmt.Printf("Your IP Address: %s\n", myip)

	allowed := net.ParseIP("")
	if len(myip) > 0 && myip.Equal(allowed) {
	} else {
		fmt.Println("you’re not allowed")

. <nil>
Your IP Address:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.