Home > other >  Calling a GET REST API in golang with a path variable
Calling a GET REST API in golang with a path variable

Time:04-27

I am trying Golang for the first time. I am trying to call a GET REST API which has a path variable. I am using net/http for that. I am trying like below but no luck so far. I need to know how I can use the path variable and pass the variable from the code. Any help or code example would be highly appreciated.

http.Get("http://127.19.0.1:8080/student/:id")

CodePudding user response:

what about

http.Get(fmt.Sprintf("http://127.19.0.1:8080/student/%s", id)

?

  •  Tags:  
  • go
  • Related