Skip to content

Instantly share code, notes, and snippets.

@puppis42
Created August 26, 2021 19:57
Show Gist options
  • Save puppis42/a1796de0c15a9c2988452fbadba161b3 to your computer and use it in GitHub Desktop.
Save puppis42/a1796de0c15a9c2988452fbadba161b3 to your computer and use it in GitHub Desktop.
package main
import (
"bytes"
"fmt"
"net/http"
)
func getData(url string) string {
response, _ := http.Get(url)
buf := new(bytes.Buffer)
buf.ReadFrom(response.Body)
return buf.String()
}
func main() {
dat := getData("https://jsonplaceholder.typicode.com/todos/1")
fmt.Println("Text:", dat)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment