Home >Backend Development >Golang >Why Does My Go Http Client Get \'Your access to this site has been restricted\' Error on Github When Curl Works?
When attempting to download zip or tar.gz files from Github using Go's http client, you may encounter the error message "Your access to this site has been restricted." Despite the error occurring with the Go client, curl may work without issue. This problem has been reported to occur on EC2 instances running Ubuntu Server 16.04 LTS in the us-west-2 region.
The following configuration details have been provided:
Here is a sample code snippet that reproduces the issue:
<code class="go">package main import ( "fmt" "io/ioutil" "net/http" ) func main() { endpoint := "https://github.com/kubeflow/manifests/archive/v1.0.2.tar.gz" // Get the data resp, err := http.Get(endpoint) if err != nil { fmt.Printf("[error] %v", err) return } defer resp.Body.Close() respData, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Printf("[error] %v", err) return } // Returns a 403 and html error page fmt.Printf("Resp:\n%v\n", string(respData)) }</code>
It's worth noting that the code runs successfully on local machines, suggesting that the issue is specific to the AWS instance.
Resolution:
A similar issue was encountered with the error message "Access to this site has been restricted." The solution involved updating the IDE (IntelliJ IDEA) and git version. This process can be completed directly within IntelliJ IDEA.
The above is the detailed content of Why Does My Go Http Client Get \'Your access to this site has been restricted\' Error on Github When Curl Works?. For more information, please follow other related articles on the PHP Chinese website!