Google Indexed Pages Checker

To create a Google Indexed Pages Checker in Go, you can follow these steps:

  1. Import the required packages:
import (
    "fmt"
    "net/http"
)

The fmt package is used for formatting and printing output, while the net/http package is used for making HTTP requests.

  1. Implement the main function:
func main() {
    url := "https://example.com" // Replace with the URL you want to check

    resp, err := http.Get(url)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    defer resp.Body.Close()

    if resp.StatusCode == http.StatusOK {
        fmt.Println("Page is indexed by Google")
    } else {
        fmt.Println("Page is not indexed by Google")
    }
}

In the main function, we define the URL that we want to check. We then use the http.Get() function to make a GET request to that URL. We check if there was an error during the request and handle it accordingly. Finally, we check the status code of the response. If it is http.StatusOK (200), it means that the page is indexed by Google. Otherwise, it is not indexed.

  1. Run the program: Save the code in a file with a .go extension (e.g., indexed_pages_checker.go). Open a terminal or command prompt, navigate to the directory where the file is saved, and run the following command:
go run indexed_pages_checker.go

Replace indexed_pages_checker.go with the actual filename if you saved it with a different name.

  1. Check the output: The program will output either "Page is indexed by Google" or "Page is not indexed by Google" based on the status code of the response.

By following these steps, you can create a simple Google Indexed Pages Checker in Go.