Sample code for 30+ languages & platforms
Go

Example: Http.DownloadSb method

See more HTTP Examples

Demonstrates the DownloadSb method.

Chilkat Go Downloads

Go
    success := false

    http := chilkat.NewHttp()
    http.SetKeepResponseBody(true)

    sb := chilkat.NewStringBuilder()
    success = http.DownloadSb("https://chilkatsoft.com/testData/helloWorld.txt","utf-8",sb)

    statusCode := http.LastStatus()
    if success == false {
        if statusCode == 0 {
            // Unable to either send the request or get the response.
            fmt.Println(http.LastErrorText())
        } else {
            // We got a response, but the status code was not in the 200s
            fmt.Println("Response status code: ", statusCode)
            // Examine the response body.
            fmt.Println("Response body:")
            fmt.Println(http.LastResponseBody())
        }

        fmt.Println("Download failed.")

    } else {
        fmt.Println("Download success, response status = ", statusCode)
        fmt.Println(*sb.GetAsString())
    }


    http.DisposeHttp()
    sb.DisposeStringBuilder()