hashicorp / go-getter

Package for downloading things from a string URL using a variety of protocols.
Mozilla Public License 2.0
1.62k stars 226 forks source link

How to download a folder via http #401

Open jiajun-c opened 1 year ago

jiajun-c commented 1 year ago

I try to download like it, but failed and the error is no source URL was returned

    var httpGetter = &getter.HttpGetter{
        // Disable pre-fetch HEAD requests
        DoNotCheckHeadFirst: true,

        // As an alternative to the above setting, you can
        // set a reasonable timeout for HEAD requests
        // HeadFirstTimeout: 10 * time.Second,

        // Read timeout for HTTP operations
        ReadTimeout: 30 * time.Second,

        // Set the maximum number of bytes
        // that can be read by the getter
        MaxBytes: 500000000, // 500 MB
    }
    dest, err := url.Parse("https://mirrors.tuna.tsinghua.edu.cn/cygwin/noarch/sha512.sum")
    fmt.Println(err)
    err = httpGetter.Get("./hack", dest)
    if err != nil {
        fmt.Println(err)
    }