Go
    http

    Go HTTP GET: net/http

    Perform GET with Go net/http

    0 views
    Updated 11/17/2025

    Ready to test this code?

    Load this example into the app

    Code Example

    Copy and run
    package main
    import (
      "net/http"; "encoding/json"; "log"
    )
    func main(){
      resp, err := http.Get("https://jsonplaceholder.typicode.com/posts/1")
      if err != nil { log.Fatal(err) }
      defer resp.Body.Close()
      var v map[string]any
      json.NewDecoder(resp.Body).Decode(&v)
      log.Println(v)
    }

    Overview

    Overview

    Use http.Get and json decoding for API calls.

    Best Practices

    • Always close response body.
    • Check status codes.
    • Use context for timeouts.

    Related Topics

    go
    http
    net/http
    api

    Ready to test APIs like a pro?

    Apicurl is a free, powerful API testing tool.