Upgrade to Pro — share decks privately, control downloads, hide ads and more …

校内LT大会2018/06/27

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →
Avatar for Hayato Suzuki Hayato Suzuki
June 27, 2018
62

 校内LT大会2018/06/27

Avatar for Hayato Suzuki

Hayato Suzuki

June 27, 2018

Transcript

  1. type User struct { ID int `json:”id”` Name string `json:”name”`

    Introduction string `json:”introduction”` } 圓鸡⡤
  2. ……… func GetEngine() *gin.Engine { router := gin.Default() router.GET(“/”, func(c

    *gin.Context) { c.String(http.StatusOK, “Hello, ੈք”) }) router.GET(“/api/users/:id”, GetUser) return router } ……… ٕ٦ذ؍ؚٝ
  3. ……… func GetUser(c *gin.Context) { id := c.Param(“id”) U :=

    User { ID: id, Name: “json_test”, Introduction: “hello, json_test”, } c.JSON(http.StatusOK, u) } ……… KTPOד鵤ׅ