Encurtar URL com GO

PHOTO EMBED

Sun Jun 05 2022 15:31:34 GMT+0000 (Coordinated Universal Time)

Saved by @canas #ruby

package main

import (
  "fmt"
"strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://dink.ga/api/criarURL"
  payload := strings.NewReader("{\n\t\"url\": \"https://example.com\"\n}")
  req, _ := http.NewRequest("POST" url, payload)

  req.Header.Add("Content-Type", "application/json")
  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))

}
content_copyCOPY