使用URL下载zip文件[关闭]

Trying to download zip file from the below URL:

https://www.3gpp.org/ftp//Specs/archive/29_series/29.512/29.512-f20.zip

I tried downloading using http.Get in Go:

resp, err := http.Get(specUrl)
if err != nil {
    return err
}

Need help in downloading the zip file.

http.get can allow to download whatever files. But the link of the question points to a file that is not found. No error is thrown, but the status code is not 200 (ok). The status code of the response has to be checked before proceeding and creating the file got from the response.

func main() {
    specUrl := "https://www.3gpp.org/ftp//Specs/archive/29_series/29.512/29.512-f20.zip"
    resp, err := http.Get(specUrl)
    if err != nil {
        fmt.Printf("err: %s", err)
    }


    defer resp.Body.Close()
    fmt.Println("status", resp.Status)
    if resp.StatusCode != 200 {
        return
    }

    // Create the file
    out, err := os.Create("test.zip")
    if err != nil {
        fmt.Printf("err: %s", err)
    }
    defer out.Close()

    // Write the body to file
    _, err = io.Copy(out, resp.Body)
    fmt.Printf("err: %s", err)
}