This is a program created at the time of the Mokumokukai held at the online salon sponsored by infrastructure engineer yuta. I made it when I was studying to get information using API in Go.
main.go
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
type Item struct {
Title string `json:"title"`
User Users
}
type Users struct {
Name string `json:"name"`
}
func main() {
targetName := "yuta_vamdemic"
getUrl := "http://qiita.com/api/v2/users/" + targetName + "/stocks?page=1&per_page=5"
resp, err := http.Get(getUrl)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
var data []Item
if err := json.Unmarshal(body, &data); err != nil {
log.Fatal(err)
}
fmt.Printf("##[%s]Stock article##\n", targetName)
for _, item := range data {
fmt.Printf("%s %s\n", item.User.Name, item.Title)
}
}
##[yuta_vamdemic]Stock article##
Silently install SQL Server Management Studio with PowerShell
[Terraform]CI for Terraform repository with CodeBuild
Kometan React Material for beginners-UI [How to use Dialog]
Square UseEffect (componentDidMount-like) that moves only once at the beginning
Understand seira React hooks from the basics(useState edition)
I was worried because I didn't know how to write the structure around here.
python
type Item struct {
Title string `json:"title"`
User Users
}
type Users struct {
Name string `json:"name"`
}
Recommended Posts