mirror of
https://github.com/hanzozt/sdk-golang.git
synced 2026-10-30 14:46:37 +00:00
30 lines
541 B
Go
30 lines
541 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
)
|
|
|
|
func main() {
|
|
target := "localhost:8090"
|
|
helloUrl := fmt.Sprintf("http://%s/hello", target)
|
|
httpClient := http.Client{}
|
|
resp, e := httpClient.Get(helloUrl)
|
|
if e != nil {
|
|
panic(e)
|
|
}
|
|
body, _ := io.ReadAll(resp.Body)
|
|
fmt.Println("Hello response:", string(body))
|
|
|
|
a := 1
|
|
b := 2
|
|
addUrl := fmt.Sprintf("http://%s/add?a=%d&b=%d", target, a, b)
|
|
resp, e = httpClient.Get(addUrl)
|
|
if e != nil {
|
|
panic(e)
|
|
}
|
|
body, _ = io.ReadAll(resp.Body)
|
|
fmt.Println("Add Result:", string(body))
|
|
}
|