回答編集履歴
2
修正
test
CHANGED
@@ -42,17 +42,17 @@
|
|
42
42
|
|
43
43
|
func Show() echo.HandlerFunc{
|
44
44
|
|
45
|
-
|
45
|
+
return func(c echo.Context) error {
|
46
46
|
|
47
|
-
d
|
47
|
+
db := dbconnect.Connect()
|
48
48
|
|
49
|
-
|
49
|
+
defer db.Close()
|
50
50
|
|
51
|
-
user
|
51
|
+
user := new(model.User)
|
52
52
|
|
53
|
-
|
53
|
+
user_id := c.Param("id")
|
54
54
|
|
55
|
-
ret
|
55
|
+
result := db.First(&user, "id = ?", user_id)
|
56
56
|
|
57
57
|
if result.RecordNotFound() {
|
58
58
|
|
1
追記
test
CHANGED
@@ -31,3 +31,43 @@
|
|
31
31
|
}
|
32
32
|
|
33
33
|
```
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
---
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
```go
|
42
|
+
|
43
|
+
func Show() echo.HandlerFunc{
|
44
|
+
|
45
|
+
db := dbconnect.Connect()
|
46
|
+
|
47
|
+
defer db.Close()
|
48
|
+
|
49
|
+
user := new(model.User)
|
50
|
+
|
51
|
+
user_id := c.Param("id")
|
52
|
+
|
53
|
+
result := db.First(&user, "id = ?", user_id)
|
54
|
+
|
55
|
+
return func(c echo.Context) error {
|
56
|
+
|
57
|
+
if result.RecordNotFound() {
|
58
|
+
|
59
|
+
fmt.Println("レコードが見つかりません")
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
return c.JSON(http.StatusOK, result)
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
```
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
ではこうしてはどうでしょう。
|