質問編集履歴

5

コードの修正

2019/07/30 18:14

投稿

kioak
kioak

スコア20

test CHANGED
File without changes
test CHANGED
@@ -222,27 +222,107 @@
222
222
 
223
223
  defer db.Close()
224
224
 
225
+ user := &model.User{
226
+
227
+ Id: model.Seq,
228
+
229
+ }
230
+
231
+ if err := c.Bind(&user); err != nil {
232
+
233
+ return err
234
+
235
+ }
236
+
237
+
238
+
239
+ model.Users[user.Id] = user
240
+
241
+ model.Seq++
242
+
243
+ db.Create(&user)
244
+
245
+ return c.JSON(http.StatusOK, user)
246
+
247
+ }
248
+
249
+ }
250
+
251
+ func FindUserById() echo.HandlerFunc {
252
+
253
+ return func(c echo.Context) (err error) {
254
+
255
+ db, err := gorm.Open("mysql", "kirohi:cSbuS2mlGo##@/subsc?charset=utf8&parseTime=True&loc=Local")
256
+
257
+ CheckConnectError(err)
258
+
259
+ defer db.Close()
260
+
225
261
  user := model.User{}
226
262
 
263
+
264
+
265
+ id := c.Param("id")
266
+
267
+ db.First(&user, id)
268
+
269
+
270
+
271
+ return c.JSON(http.StatusOK, user)
272
+
273
+ }
274
+
275
+ }
276
+
277
+
278
+
279
+ func UpdateUser() echo.HandlerFunc {
280
+
281
+ return func(c echo.Context) (err error) {
282
+
283
+ db, err := gorm.Open("mysql", "kirohi:cSbuS2mlGo##@/subsc?charset=utf8&parseTime=True&loc=Local")
284
+
285
+ CheckConnectError(err)
286
+
287
+ defer db.Close()
288
+
289
+
290
+
291
+ user := model.User{}
292
+
227
- if err := c.Bind(&user); err != nil {
293
+ if err = c.Bind(user); err != nil {
228
-
294
+
229
- return err
295
+ return
230
296
 
231
297
  }
232
298
 
233
-
299
+ id, _ := strconv.Atoi(c.Param("id"))
300
+
234
-
301
+ db.Where("Id=?", id).Find(&user)
302
+
303
+
304
+
305
+ user.Name = c.Param("name")
306
+
307
+
308
+
235
- db.Create(&user)
309
+ fmt.Println(user.Name)
310
+
236
-
311
+ // //model.Users[id].Name = "あああ"
312
+
313
+ // //fmt.Println(model.Users[id])
314
+
315
+ // return c.JSON(http.StatusOK, user)
316
+
237
- return c.String(http.StatusOK, "OK")
317
+ return c.JSON(http.StatusOK, "ok")
238
-
318
+
239
- }
319
+ }
240
-
320
+
241
- }
321
+ }
242
-
243
-
244
-
322
+
323
+
324
+
245
- func FindUserById() echo.HandlerFunc {
325
+ func DeleteUser() echo.HandlerFunc {
246
326
 
247
327
  return func(c echo.Context) (err error) {
248
328
 
@@ -256,88 +336,6 @@
256
336
 
257
337
 
258
338
 
259
- id := c.Param("id")
260
-
261
- db.First(&user, id)
262
-
263
-
264
-
265
- return c.JSON(http.StatusOK, user)
266
-
267
- }
268
-
269
- }
270
-
271
-
272
-
273
- func UpdateUser() echo.HandlerFunc {
274
-
275
- // emailをUpdateする処理
276
-
277
- return func(c echo.Context) (err error) {
278
-
279
- db, err := gorm.Open("mysql", "kirohi:cSbuS2mlGo##@/subsc?charset=utf8&parseTime=True&loc=Local")
280
-
281
- CheckConnectError(err)
282
-
283
- defer db.Close()
284
-
285
-
286
-
287
- user := new(model.User)
288
-
289
- if err := c.Bind(user); err != nil {
290
-
291
- return err
292
-
293
- }
294
-
295
- id, _ := strconv.Atoi(c.Param("id"))
296
-
297
- // db.Where("id=?", id).Find(&user)
298
-
299
- // ex := model.Users[id]
300
-
301
- // ex.Name = user.Name
302
-
303
- // db.Update(&user)
304
-
305
- // user := new(model.User)
306
-
307
- // if err := c.Bind(user); err != nil {
308
-
309
- // return err
310
-
311
- // }
312
-
313
- // // model.Users[id].Name = user.Name
314
-
315
- // // db.Where("id", id).Find(&user)
316
-
317
- model.Users[id].Name = user.Name
318
-
319
- return c.JSON(http.StatusOK, model.Users[id])
320
-
321
- }
322
-
323
- }
324
-
325
-
326
-
327
- func DeleteUser() echo.HandlerFunc {
328
-
329
- return func(c echo.Context) (err error) {
330
-
331
- db, err := gorm.Open("mysql", "kirohi:cSbuS2mlGo##@/subsc?charset=utf8&parseTime=True&loc=Local")
332
-
333
- CheckConnectError(err)
334
-
335
- defer db.Close()
336
-
337
- user := model.User{}
338
-
339
-
340
-
341
339
  name := c.Param("name")
342
340
 
343
341
 

4

誤字

2019/07/30 18:14

投稿

kioak
kioak

スコア20

test CHANGED
File without changes
test CHANGED
@@ -44,13 +44,241 @@
44
44
 
45
45
  func UpdateUser() echo.HandlerFunc {
46
46
 
47
+ return func(c echo.Context) (err error) {
48
+
49
+ db, err := gorm.Open("mysql", "mysql設定")
50
+
51
+ CheckConnectError(err) //エラーハンドリングの関数
52
+
53
+ defer db.Close()
54
+
55
+
56
+
57
+ user := new(model.User)
58
+
59
+ if err := c.Bind(user); err != nil {
60
+
61
+ return err
62
+
63
+ }
64
+
65
+ id, _ := strconv.Atoi(c.Param("id"))
66
+
67
+ model.Users[id].Name = user.Name
68
+
69
+ return c.JSON(http.StatusOK, "ok")
70
+
71
+ }
72
+
73
+ }
74
+
75
+ ```
76
+
77
+
78
+
79
+ model.Users[id].Nameは,modelパッケージのUsers変数をidで取ってきてNameに代入がしたくて書いています.
80
+
81
+ 公式のドキュメントを参考にしました.
82
+
83
+
84
+
85
+ ```
86
+
87
+ ## model/user.go
88
+
89
+ ~略
90
+
91
+ var (
92
+
93
+ Users = map[int]*User{}
94
+
95
+ Seq = 1
96
+
97
+ )
98
+
99
+ 略~
100
+
101
+ ```
102
+
103
+
104
+
105
+ [https://echo.labstack.com/cookbook/crud](https://echo.labstack.com/cookbook/crud)
106
+
107
+
108
+
109
+
110
+
111
+ 処理がおかしいところはありますでしょうか.
112
+
113
+ よろしくお願いします
114
+
115
+
116
+
117
+ ## 追記
118
+
119
+ ログはこのようになっております.
120
+
121
+
122
+
123
+ ```log
124
+
125
+ time:2019-07-26T15:37:53+09:00 host:::1
126
+
127
+ forwardedfor: req:-
128
+
129
+ status:500
130
+
131
+ method:PUT
132
+
133
+ uri:/api/v1/users/3
134
+
135
+ size:36 referer:
136
+
137
+ ua:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36
138
+
139
+ reqtime_ns:1895431
140
+
141
+ cache:- runtime:-
142
+
143
+ apptime:-
144
+
145
+ vhost:localhost:8888
146
+
147
+ reqtime_human:1.895431ms
148
+
149
+ x-request-id: host:localhost:8888
150
+
151
+ ```
152
+
153
+
154
+
155
+ 下記はかなり見辛いログですが,載せておきます.
156
+
157
+
158
+
159
+ ``` log
160
+
161
+ {"time":"2019-07-26T15:37:53.480874+09:00","level":"-","prefix":"echo","file":"recover.go","line":"73","message":"[PANIC RECOVER] runtime error: invalid memory address or nil pointer dereference goroutine 50 [running]:\necho/middleware.RecoverWithConfig.func1.1.1(0x156b148, 0x1000, 0xc000060000, 0x160b140, 0xc0002b2120)\n\t/Users/kirohi/go/src/echo/middleware/recover.go:71 +0xf1\npanic(0x14cc0e0, 0x195b440)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/runtime/panic.go:522 +0x1b5\ngithub.com/ia17011/subsc/backend/api.UpdateUser.func1(0x160b140, 0xc0002b2120, 0x0, 0x0)\n\t/Users/kirohi/go/src/github.com/ia17011/subsc/backend/api/user.go:74 +0x19d\ngithub.com/labstack/echo.(*Echo).add.func1(0x160b140, 0xc0002b2120, 0xc0002160a0, 0xf)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:505 +0x87\ngithub.com/ia17011/subsc/backend/api/middlewares.serverHeader.func1(0x160b140, 0xc0002b2120, 0x156b148, 0x1000)\n\t/Users/kirohi/go/src/github.com/ia17011/subsc/backend/api/middlewares/mainMiddlewares.go:25 +0x235\necho/middleware.RecoverWithConfig.func1.1(0x160b140, 0xc0002b2120, 0x0, 0x0)\n\t/Users/kirohi/go/src/echo/middleware/recover.go:78 +0xd5\necho/middleware.LoggerWithConfig.func2.1(0x160b140, 0xc0002b2120, 0x3, 0x4)\n\t/Users/kirohi/go/src/echo/middleware/logger.go:119 +0x1c0\ngithub.com/labstack/echo.(*Echo).ServeHTTP(0xc00028a000, 0x15fe860, 0xc0002bc000, 0xc0001e8a00)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:616 +0x22d\nnet/http.serverHandler.ServeHTTP(0xc000226750, 0x15fe860, 0xc0002bc000, 0xc0001e8a00)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2774 +0xa8\nnet/http.(*conn).serve(0xc00021e0a0, 0x15ff560, 0xc0001ecc00)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1878 +0x851\ncreated by net/http.(*Server).Serve\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2884 +0x2f4\n\ngoroutine 1 [IO wait]:\ninternal/poll.runtime_pollWait(0x1e91ea8, 0x72, 0x0)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/runtime/netpoll.go:182 +0x56\ninternal/poll.(*pollDesc).wait(0xc000232818, 0x72, 0x0, 0x0, 0x154be4a)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/internal/poll/fd_poll_runtime.go:87 +0x9b\ninternal/poll.(*pollDesc).waitRead(...)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/internal/poll/fd_poll_runtime.go:92\ninternal/poll.(*FD).Accept(0xc000232800, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/internal/poll/fd_unix.go:384 +0x1ba\nnet.(*netFD).accept(0xc000232800, 0x30, 0x50, 0x50)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/fd_unix.go:238 +0x42\nnet.(*TCPListener).accept(0xc0002222f8, 0xc0f05880cb, 0xc000088000, 0xc00010dd00)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/tcpsock_posix.go:139 +0x32\nnet.(*TCPListener).AcceptTCP(0xc0002222f8, 0x100000001, 0xc00010dd30, 0x104c368)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/tcpsock.go:247 +0x48\ngithub.com/labstack/echo.tcpKeepAliveListener.Accept(0xc0002222f8, 0xc00010dd58, 0x10afda6, 0x5d3a9fc1, 0x1036bcf)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:820 +0x2f\nnet/http.(*Server).Serve(0xc000226750, 0x15fe4e0, 0xc000222300, 0x0, 0x0)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2859 +0x22d\ngithub.com/labstack/echo.(*Echo).StartServer(0xc00028a000, 0xc000226750, 0x0, 0x0)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:707 +0x388\ngithub.com/labstack/echo.(*Echo).Start(...)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:627\nmain.main()\n\t/Users/kirohi/go/src/github.com/ia17011/subsc/backend/main.go:16 +0x67\n\ngoroutine 51 [runnable]:\ndatabase/sql.(*DB).connectionOpener(0xc0002ca000, 0x15ff560, 0xc000220300)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/database/sql/sql.go:1000 +0xe8\ncreated by database/sql.OpenDB\n\t/usr/local/Cellar/go/1.12.5/libexec/src/database/sql/sql.go:670 +0x15e\n\ngoroutine 35 [runnable]:\ngithub.com/go-sql-driver/mysql.(*mysqlConn).startWatcher.func1(0xc0001f9080, 0xc0002c6120, 0xc0001f62a0)\n\t/Users/kirohi/go/src/github.com/go-sql-driver/mysql/connection.go:619 +0xbf\ncreated by github.com/go-sql-driver/mysql.(*mysqlConn).startWatcher\n\t/Users/kirohi/go/src/github.com/go-sql-driver/mysql/connection.go:616 +0xbe\n\ngoroutine 52 [runnable]:\ndatabase/sql.(*DB).connectionResetter(0xc0002ca000, 0x15ff560, 0xc000220300)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/database/sql/sql.go:1013 +0x\n"}
162
+
163
+ ```
164
+
165
+
166
+
167
+ ## api/user.goと送信しているjsonの追記
168
+
169
+ ```go
170
+
171
+ package api
172
+
173
+
174
+
175
+ import (
176
+
177
+ "fmt"
178
+
179
+ "net/http"
180
+
181
+ "strconv"
182
+
183
+
184
+
185
+ "github.com/ia17011/subsc/backend/model"
186
+
187
+ "github.com/jinzhu/gorm"
188
+
189
+ "github.com/labstack/echo"
190
+
191
+ uuid "github.com/satori/go.uuid"
192
+
193
+ )
194
+
195
+
196
+
197
+ func getUUID() string {
198
+
199
+ u, err := uuid.NewV4()
200
+
201
+ if err != nil {
202
+
203
+ fmt.Printf("Something went wrong: %s", err)
204
+
205
+ }
206
+
207
+ uu := u.String()
208
+
209
+ return uu
210
+
211
+ }
212
+
213
+
214
+
215
+ func CreateUser() echo.HandlerFunc {
216
+
217
+ return func(c echo.Context) (err error) {
218
+
219
+ db, err := gorm.Open("mysql", "kirohi:cSbuS2mlGo##@/subsc?charset=utf8&parseTime=True&loc=Local")
220
+
221
+ CheckConnectError(err)
222
+
223
+ defer db.Close()
224
+
225
+ user := model.User{}
226
+
227
+ if err := c.Bind(&user); err != nil {
228
+
229
+ return err
230
+
231
+ }
232
+
233
+
234
+
235
+ db.Create(&user)
236
+
237
+ return c.String(http.StatusOK, "OK")
238
+
239
+ }
240
+
241
+ }
242
+
243
+
244
+
245
+ func FindUserById() echo.HandlerFunc {
246
+
247
+ return func(c echo.Context) (err error) {
248
+
249
+ db, err := gorm.Open("mysql", "kirohi:cSbuS2mlGo##@/subsc?charset=utf8&parseTime=True&loc=Local")
250
+
251
+ CheckConnectError(err)
252
+
253
+ defer db.Close()
254
+
255
+ user := model.User{}
256
+
257
+
258
+
259
+ id := c.Param("id")
260
+
261
+ db.First(&user, id)
262
+
263
+
264
+
265
+ return c.JSON(http.StatusOK, user)
266
+
267
+ }
268
+
269
+ }
270
+
271
+
272
+
273
+ func UpdateUser() echo.HandlerFunc {
274
+
47
275
  // emailをUpdateする処理
48
276
 
49
277
  return func(c echo.Context) (err error) {
50
278
 
51
- db, err := gorm.Open("mysql", "mysql設定")
279
+ db, err := gorm.Open("mysql", "kirohi:cSbuS2mlGo##@/subsc?charset=utf8&parseTime=True&loc=Local")
52
-
280
+
53
- CheckConnectError(err) //エラーハンドリングの関数
281
+ CheckConnectError(err)
54
282
 
55
283
  defer db.Close()
56
284
 
@@ -66,155 +294,37 @@
66
294
 
67
295
  id, _ := strconv.Atoi(c.Param("id"))
68
296
 
297
+ // db.Where("id=?", id).Find(&user)
298
+
299
+ // ex := model.Users[id]
300
+
301
+ // ex.Name = user.Name
302
+
303
+ // db.Update(&user)
304
+
305
+ // user := new(model.User)
306
+
307
+ // if err := c.Bind(user); err != nil {
308
+
309
+ // return err
310
+
311
+ // }
312
+
313
+ // // model.Users[id].Name = user.Name
314
+
315
+ // // db.Where("id", id).Find(&user)
316
+
69
317
  model.Users[id].Name = user.Name
70
318
 
71
- return c.JSON(http.StatusOK, "ok")
72
-
73
- }
74
-
75
- }
76
-
77
- ```
78
-
79
-
80
-
81
- model.Users[id].Nameは,modelパッケージのUsers変数をidで取ってきてNameに代入がしたくて書いています.
82
-
83
- 公式のドキュメントを参考にしました.
84
-
85
-
86
-
87
- ```
88
-
89
- ## model/user.go
90
-
91
- ~略
92
-
93
- var (
94
-
95
- Users = map[int]*User{}
96
-
97
- Seq = 1
98
-
99
- )
100
-
101
- 略~
102
-
103
- ```
104
-
105
-
106
-
107
- [https://echo.labstack.com/cookbook/crud](https://echo.labstack.com/cookbook/crud)
108
-
109
-
110
-
111
-
112
-
113
- 処理がおかしいところはありますでしょうか.
114
-
115
- よろしくお願いします
116
-
117
-
118
-
119
- ## 追記
120
-
121
- ログはこのようになっております.
122
-
123
-
124
-
125
- ```log
126
-
127
- time:2019-07-26T15:37:53+09:00 host:::1
128
-
129
- forwardedfor: req:-
130
-
131
- status:500
132
-
133
- method:PUT
134
-
135
- uri:/api/v1/users/3
136
-
137
- size:36 referer:
138
-
139
- ua:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36
140
-
141
- reqtime_ns:1895431
142
-
143
- cache:- runtime:-
144
-
145
- apptime:-
146
-
147
- vhost:localhost:8888
148
-
149
- reqtime_human:1.895431ms
150
-
151
- x-request-id: host:localhost:8888
152
-
153
- ```
154
-
155
-
156
-
157
- 下記はかなり見辛いログですが,載せておきます.
158
-
159
-
160
-
161
- ``` log
162
-
163
- {"time":"2019-07-26T15:37:53.480874+09:00","level":"-","prefix":"echo","file":"recover.go","line":"73","message":"[PANIC RECOVER] runtime error: invalid memory address or nil pointer dereference goroutine 50 [running]:\necho/middleware.RecoverWithConfig.func1.1.1(0x156b148, 0x1000, 0xc000060000, 0x160b140, 0xc0002b2120)\n\t/Users/kirohi/go/src/echo/middleware/recover.go:71 +0xf1\npanic(0x14cc0e0, 0x195b440)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/runtime/panic.go:522 +0x1b5\ngithub.com/ia17011/subsc/backend/api.UpdateUser.func1(0x160b140, 0xc0002b2120, 0x0, 0x0)\n\t/Users/kirohi/go/src/github.com/ia17011/subsc/backend/api/user.go:74 +0x19d\ngithub.com/labstack/echo.(*Echo).add.func1(0x160b140, 0xc0002b2120, 0xc0002160a0, 0xf)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:505 +0x87\ngithub.com/ia17011/subsc/backend/api/middlewares.serverHeader.func1(0x160b140, 0xc0002b2120, 0x156b148, 0x1000)\n\t/Users/kirohi/go/src/github.com/ia17011/subsc/backend/api/middlewares/mainMiddlewares.go:25 +0x235\necho/middleware.RecoverWithConfig.func1.1(0x160b140, 0xc0002b2120, 0x0, 0x0)\n\t/Users/kirohi/go/src/echo/middleware/recover.go:78 +0xd5\necho/middleware.LoggerWithConfig.func2.1(0x160b140, 0xc0002b2120, 0x3, 0x4)\n\t/Users/kirohi/go/src/echo/middleware/logger.go:119 +0x1c0\ngithub.com/labstack/echo.(*Echo).ServeHTTP(0xc00028a000, 0x15fe860, 0xc0002bc000, 0xc0001e8a00)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:616 +0x22d\nnet/http.serverHandler.ServeHTTP(0xc000226750, 0x15fe860, 0xc0002bc000, 0xc0001e8a00)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2774 +0xa8\nnet/http.(*conn).serve(0xc00021e0a0, 0x15ff560, 0xc0001ecc00)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1878 +0x851\ncreated by net/http.(*Server).Serve\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2884 +0x2f4\n\ngoroutine 1 [IO wait]:\ninternal/poll.runtime_pollWait(0x1e91ea8, 0x72, 0x0)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/runtime/netpoll.go:182 +0x56\ninternal/poll.(*pollDesc).wait(0xc000232818, 0x72, 0x0, 0x0, 0x154be4a)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/internal/poll/fd_poll_runtime.go:87 +0x9b\ninternal/poll.(*pollDesc).waitRead(...)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/internal/poll/fd_poll_runtime.go:92\ninternal/poll.(*FD).Accept(0xc000232800, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/internal/poll/fd_unix.go:384 +0x1ba\nnet.(*netFD).accept(0xc000232800, 0x30, 0x50, 0x50)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/fd_unix.go:238 +0x42\nnet.(*TCPListener).accept(0xc0002222f8, 0xc0f05880cb, 0xc000088000, 0xc00010dd00)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/tcpsock_posix.go:139 +0x32\nnet.(*TCPListener).AcceptTCP(0xc0002222f8, 0x100000001, 0xc00010dd30, 0x104c368)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/tcpsock.go:247 +0x48\ngithub.com/labstack/echo.tcpKeepAliveListener.Accept(0xc0002222f8, 0xc00010dd58, 0x10afda6, 0x5d3a9fc1, 0x1036bcf)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:820 +0x2f\nnet/http.(*Server).Serve(0xc000226750, 0x15fe4e0, 0xc000222300, 0x0, 0x0)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2859 +0x22d\ngithub.com/labstack/echo.(*Echo).StartServer(0xc00028a000, 0xc000226750, 0x0, 0x0)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:707 +0x388\ngithub.com/labstack/echo.(*Echo).Start(...)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:627\nmain.main()\n\t/Users/kirohi/go/src/github.com/ia17011/subsc/backend/main.go:16 +0x67\n\ngoroutine 51 [runnable]:\ndatabase/sql.(*DB).connectionOpener(0xc0002ca000, 0x15ff560, 0xc000220300)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/database/sql/sql.go:1000 +0xe8\ncreated by database/sql.OpenDB\n\t/usr/local/Cellar/go/1.12.5/libexec/src/database/sql/sql.go:670 +0x15e\n\ngoroutine 35 [runnable]:\ngithub.com/go-sql-driver/mysql.(*mysqlConn).startWatcher.func1(0xc0001f9080, 0xc0002c6120, 0xc0001f62a0)\n\t/Users/kirohi/go/src/github.com/go-sql-driver/mysql/connection.go:619 +0xbf\ncreated by github.com/go-sql-driver/mysql.(*mysqlConn).startWatcher\n\t/Users/kirohi/go/src/github.com/go-sql-driver/mysql/connection.go:616 +0xbe\n\ngoroutine 52 [runnable]:\ndatabase/sql.(*DB).connectionResetter(0xc0002ca000, 0x15ff560, 0xc000220300)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/database/sql/sql.go:1013 +0x\n"}
164
-
165
- ```
166
-
167
-
168
-
169
- ## api/user.goと送信しているjsonの追記
170
-
171
- ```go
172
-
173
- package api
174
-
175
-
176
-
177
- import (
178
-
179
- "fmt"
180
-
181
- "net/http"
182
-
183
- "strconv"
184
-
185
-
186
-
187
- "github.com/ia17011/subsc/backend/model"
188
-
189
- "github.com/jinzhu/gorm"
190
-
191
- "github.com/labstack/echo"
192
-
193
- uuid "github.com/satori/go.uuid"
194
-
195
- )
196
-
197
-
198
-
199
- func getUUID() string {
200
-
201
- u, err := uuid.NewV4()
202
-
203
- if err != nil {
204
-
205
- fmt.Printf("Something went wrong: %s", err)
206
-
207
- }
208
-
209
- uu := u.String()
210
-
211
- return uu
212
-
213
- }
214
-
215
-
216
-
217
- func CreateUser() echo.HandlerFunc {
319
+ return c.JSON(http.StatusOK, model.Users[id])
320
+
321
+ }
322
+
323
+ }
324
+
325
+
326
+
327
+ func DeleteUser() echo.HandlerFunc {
218
328
 
219
329
  return func(c echo.Context) (err error) {
220
330
 
@@ -226,118 +336,6 @@
226
336
 
227
337
  user := model.User{}
228
338
 
229
- if err := c.Bind(&user); err != nil {
230
-
231
- return err
232
-
233
- }
234
-
235
-
236
-
237
- db.Create(&user)
238
-
239
- return c.String(http.StatusOK, "OK")
240
-
241
- }
242
-
243
- }
244
-
245
-
246
-
247
- func FindUserById() echo.HandlerFunc {
248
-
249
- return func(c echo.Context) (err error) {
250
-
251
- db, err := gorm.Open("mysql", "kirohi:cSbuS2mlGo##@/subsc?charset=utf8&parseTime=True&loc=Local")
252
-
253
- CheckConnectError(err)
254
-
255
- defer db.Close()
256
-
257
- user := model.User{}
258
-
259
-
260
-
261
- id := c.Param("id")
262
-
263
- db.First(&user, id)
264
-
265
-
266
-
267
- return c.JSON(http.StatusOK, user)
268
-
269
- }
270
-
271
- }
272
-
273
-
274
-
275
- func UpdateUser() echo.HandlerFunc {
276
-
277
- // emailをUpdateする処理
278
-
279
- return func(c echo.Context) (err error) {
280
-
281
- db, err := gorm.Open("mysql", "kirohi:cSbuS2mlGo##@/subsc?charset=utf8&parseTime=True&loc=Local")
282
-
283
- CheckConnectError(err)
284
-
285
- defer db.Close()
286
-
287
-
288
-
289
- user := new(model.User)
290
-
291
- if err := c.Bind(user); err != nil {
292
-
293
- return err
294
-
295
- }
296
-
297
- id, _ := strconv.Atoi(c.Param("id"))
298
-
299
- // db.Where("id=?", id).Find(&user)
300
-
301
- // ex := model.Users[id]
302
-
303
- // ex.Name = user.Name
304
-
305
- // db.Update(&user)
306
-
307
- // user := new(model.User)
308
-
309
- // if err := c.Bind(user); err != nil {
310
-
311
- // return err
312
-
313
- // }
314
-
315
- // // model.Users[id].Name = user.Name
316
-
317
- // // db.Where("id", id).Find(&user)
318
-
319
- model.Users[id].Name = user.Name
320
-
321
- return c.JSON(http.StatusOK, model.Users[id])
322
-
323
- }
324
-
325
- }
326
-
327
-
328
-
329
- func DeleteUser() echo.HandlerFunc {
330
-
331
- return func(c echo.Context) (err error) {
332
-
333
- db, err := gorm.Open("mysql", "kirohi:cSbuS2mlGo##@/subsc?charset=utf8&parseTime=True&loc=Local")
334
-
335
- CheckConnectError(err)
336
-
337
- defer db.Close()
338
-
339
- user := model.User{}
340
-
341
339
 
342
340
 
343
341
  name := c.Param("name")

3

api/user.go jsonについての追記

2019/07/30 17:26

投稿

kioak
kioak

スコア20

test CHANGED
File without changes
test CHANGED
@@ -163,3 +163,241 @@
163
163
  {"time":"2019-07-26T15:37:53.480874+09:00","level":"-","prefix":"echo","file":"recover.go","line":"73","message":"[PANIC RECOVER] runtime error: invalid memory address or nil pointer dereference goroutine 50 [running]:\necho/middleware.RecoverWithConfig.func1.1.1(0x156b148, 0x1000, 0xc000060000, 0x160b140, 0xc0002b2120)\n\t/Users/kirohi/go/src/echo/middleware/recover.go:71 +0xf1\npanic(0x14cc0e0, 0x195b440)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/runtime/panic.go:522 +0x1b5\ngithub.com/ia17011/subsc/backend/api.UpdateUser.func1(0x160b140, 0xc0002b2120, 0x0, 0x0)\n\t/Users/kirohi/go/src/github.com/ia17011/subsc/backend/api/user.go:74 +0x19d\ngithub.com/labstack/echo.(*Echo).add.func1(0x160b140, 0xc0002b2120, 0xc0002160a0, 0xf)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:505 +0x87\ngithub.com/ia17011/subsc/backend/api/middlewares.serverHeader.func1(0x160b140, 0xc0002b2120, 0x156b148, 0x1000)\n\t/Users/kirohi/go/src/github.com/ia17011/subsc/backend/api/middlewares/mainMiddlewares.go:25 +0x235\necho/middleware.RecoverWithConfig.func1.1(0x160b140, 0xc0002b2120, 0x0, 0x0)\n\t/Users/kirohi/go/src/echo/middleware/recover.go:78 +0xd5\necho/middleware.LoggerWithConfig.func2.1(0x160b140, 0xc0002b2120, 0x3, 0x4)\n\t/Users/kirohi/go/src/echo/middleware/logger.go:119 +0x1c0\ngithub.com/labstack/echo.(*Echo).ServeHTTP(0xc00028a000, 0x15fe860, 0xc0002bc000, 0xc0001e8a00)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:616 +0x22d\nnet/http.serverHandler.ServeHTTP(0xc000226750, 0x15fe860, 0xc0002bc000, 0xc0001e8a00)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2774 +0xa8\nnet/http.(*conn).serve(0xc00021e0a0, 0x15ff560, 0xc0001ecc00)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1878 +0x851\ncreated by net/http.(*Server).Serve\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2884 +0x2f4\n\ngoroutine 1 [IO wait]:\ninternal/poll.runtime_pollWait(0x1e91ea8, 0x72, 0x0)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/runtime/netpoll.go:182 +0x56\ninternal/poll.(*pollDesc).wait(0xc000232818, 0x72, 0x0, 0x0, 0x154be4a)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/internal/poll/fd_poll_runtime.go:87 +0x9b\ninternal/poll.(*pollDesc).waitRead(...)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/internal/poll/fd_poll_runtime.go:92\ninternal/poll.(*FD).Accept(0xc000232800, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/internal/poll/fd_unix.go:384 +0x1ba\nnet.(*netFD).accept(0xc000232800, 0x30, 0x50, 0x50)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/fd_unix.go:238 +0x42\nnet.(*TCPListener).accept(0xc0002222f8, 0xc0f05880cb, 0xc000088000, 0xc00010dd00)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/tcpsock_posix.go:139 +0x32\nnet.(*TCPListener).AcceptTCP(0xc0002222f8, 0x100000001, 0xc00010dd30, 0x104c368)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/tcpsock.go:247 +0x48\ngithub.com/labstack/echo.tcpKeepAliveListener.Accept(0xc0002222f8, 0xc00010dd58, 0x10afda6, 0x5d3a9fc1, 0x1036bcf)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:820 +0x2f\nnet/http.(*Server).Serve(0xc000226750, 0x15fe4e0, 0xc000222300, 0x0, 0x0)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2859 +0x22d\ngithub.com/labstack/echo.(*Echo).StartServer(0xc00028a000, 0xc000226750, 0x0, 0x0)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:707 +0x388\ngithub.com/labstack/echo.(*Echo).Start(...)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:627\nmain.main()\n\t/Users/kirohi/go/src/github.com/ia17011/subsc/backend/main.go:16 +0x67\n\ngoroutine 51 [runnable]:\ndatabase/sql.(*DB).connectionOpener(0xc0002ca000, 0x15ff560, 0xc000220300)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/database/sql/sql.go:1000 +0xe8\ncreated by database/sql.OpenDB\n\t/usr/local/Cellar/go/1.12.5/libexec/src/database/sql/sql.go:670 +0x15e\n\ngoroutine 35 [runnable]:\ngithub.com/go-sql-driver/mysql.(*mysqlConn).startWatcher.func1(0xc0001f9080, 0xc0002c6120, 0xc0001f62a0)\n\t/Users/kirohi/go/src/github.com/go-sql-driver/mysql/connection.go:619 +0xbf\ncreated by github.com/go-sql-driver/mysql.(*mysqlConn).startWatcher\n\t/Users/kirohi/go/src/github.com/go-sql-driver/mysql/connection.go:616 +0xbe\n\ngoroutine 52 [runnable]:\ndatabase/sql.(*DB).connectionResetter(0xc0002ca000, 0x15ff560, 0xc000220300)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/database/sql/sql.go:1013 +0x\n"}
164
164
 
165
165
  ```
166
+
167
+
168
+
169
+ ## api/user.goと送信しているjsonの追記
170
+
171
+ ```go
172
+
173
+ package api
174
+
175
+
176
+
177
+ import (
178
+
179
+ "fmt"
180
+
181
+ "net/http"
182
+
183
+ "strconv"
184
+
185
+
186
+
187
+ "github.com/ia17011/subsc/backend/model"
188
+
189
+ "github.com/jinzhu/gorm"
190
+
191
+ "github.com/labstack/echo"
192
+
193
+ uuid "github.com/satori/go.uuid"
194
+
195
+ )
196
+
197
+
198
+
199
+ func getUUID() string {
200
+
201
+ u, err := uuid.NewV4()
202
+
203
+ if err != nil {
204
+
205
+ fmt.Printf("Something went wrong: %s", err)
206
+
207
+ }
208
+
209
+ uu := u.String()
210
+
211
+ return uu
212
+
213
+ }
214
+
215
+
216
+
217
+ func CreateUser() echo.HandlerFunc {
218
+
219
+ return func(c echo.Context) (err error) {
220
+
221
+ db, err := gorm.Open("mysql", "kirohi:cSbuS2mlGo##@/subsc?charset=utf8&parseTime=True&loc=Local")
222
+
223
+ CheckConnectError(err)
224
+
225
+ defer db.Close()
226
+
227
+ user := model.User{}
228
+
229
+ if err := c.Bind(&user); err != nil {
230
+
231
+ return err
232
+
233
+ }
234
+
235
+
236
+
237
+ db.Create(&user)
238
+
239
+ return c.String(http.StatusOK, "OK")
240
+
241
+ }
242
+
243
+ }
244
+
245
+
246
+
247
+ func FindUserById() echo.HandlerFunc {
248
+
249
+ return func(c echo.Context) (err error) {
250
+
251
+ db, err := gorm.Open("mysql", "kirohi:cSbuS2mlGo##@/subsc?charset=utf8&parseTime=True&loc=Local")
252
+
253
+ CheckConnectError(err)
254
+
255
+ defer db.Close()
256
+
257
+ user := model.User{}
258
+
259
+
260
+
261
+ id := c.Param("id")
262
+
263
+ db.First(&user, id)
264
+
265
+
266
+
267
+ return c.JSON(http.StatusOK, user)
268
+
269
+ }
270
+
271
+ }
272
+
273
+
274
+
275
+ func UpdateUser() echo.HandlerFunc {
276
+
277
+ // emailをUpdateする処理
278
+
279
+ return func(c echo.Context) (err error) {
280
+
281
+ db, err := gorm.Open("mysql", "kirohi:cSbuS2mlGo##@/subsc?charset=utf8&parseTime=True&loc=Local")
282
+
283
+ CheckConnectError(err)
284
+
285
+ defer db.Close()
286
+
287
+
288
+
289
+ user := new(model.User)
290
+
291
+ if err := c.Bind(user); err != nil {
292
+
293
+ return err
294
+
295
+ }
296
+
297
+ id, _ := strconv.Atoi(c.Param("id"))
298
+
299
+ // db.Where("id=?", id).Find(&user)
300
+
301
+ // ex := model.Users[id]
302
+
303
+ // ex.Name = user.Name
304
+
305
+ // db.Update(&user)
306
+
307
+ // user := new(model.User)
308
+
309
+ // if err := c.Bind(user); err != nil {
310
+
311
+ // return err
312
+
313
+ // }
314
+
315
+ // // model.Users[id].Name = user.Name
316
+
317
+ // // db.Where("id", id).Find(&user)
318
+
319
+ model.Users[id].Name = user.Name
320
+
321
+ return c.JSON(http.StatusOK, model.Users[id])
322
+
323
+ }
324
+
325
+ }
326
+
327
+
328
+
329
+ func DeleteUser() echo.HandlerFunc {
330
+
331
+ return func(c echo.Context) (err error) {
332
+
333
+ db, err := gorm.Open("mysql", "kirohi:cSbuS2mlGo##@/subsc?charset=utf8&parseTime=True&loc=Local")
334
+
335
+ CheckConnectError(err)
336
+
337
+ defer db.Close()
338
+
339
+ user := model.User{}
340
+
341
+
342
+
343
+ name := c.Param("name")
344
+
345
+
346
+
347
+ db.Where("name=?", name).Find(&user)
348
+
349
+ db.Delete(&user)
350
+
351
+
352
+
353
+ return c.NoContent(http.StatusOK)
354
+
355
+ }
356
+
357
+ }
358
+
359
+
360
+
361
+ func NewUser(user *model.User) {
362
+
363
+ db, err := gorm.Open("mysql", "kirohi:cSbuS2mlGo##@/subsc?charset=utf8&parseTime=True&loc=Local")
364
+
365
+ CheckConnectError(err)
366
+
367
+ defer db.Close()
368
+
369
+ db.Create(user)
370
+
371
+ }
372
+
373
+
374
+
375
+ func FindUser(u *model.User) *model.User {
376
+
377
+ db, err := gorm.Open("mysql", "kirohi:cSbuS2mlGo##@/subsc?charset=utf8&parseTime=True&loc=Local")
378
+
379
+ CheckConnectError(err)
380
+
381
+ defer db.Close()
382
+
383
+
384
+
385
+ user := model.User{}
386
+
387
+ db.Where(u).First(&user)
388
+
389
+ return &user
390
+
391
+ }
392
+
393
+
394
+
395
+ ```
396
+
397
+
398
+
399
+ json
400
+
401
+ http://localhost:8888/api/v1/users/3 というurlに対して,{ "name" : "あああ" } というbodyをContent-Type application/json,POSTで投げています.
402
+
403
+ ここでidが3であるユーザーの存在は,FindByUserID(),すなわちGETリクエストで確認できています.

2

ログを追加

2019/07/26 18:38

投稿

kioak
kioak

スコア20

test CHANGED
File without changes
test CHANGED
@@ -113,3 +113,53 @@
113
113
  処理がおかしいところはありますでしょうか.
114
114
 
115
115
  よろしくお願いします
116
+
117
+
118
+
119
+ ## 追記
120
+
121
+ ログはこのようになっております.
122
+
123
+
124
+
125
+ ```log
126
+
127
+ time:2019-07-26T15:37:53+09:00 host:::1
128
+
129
+ forwardedfor: req:-
130
+
131
+ status:500
132
+
133
+ method:PUT
134
+
135
+ uri:/api/v1/users/3
136
+
137
+ size:36 referer:
138
+
139
+ ua:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36
140
+
141
+ reqtime_ns:1895431
142
+
143
+ cache:- runtime:-
144
+
145
+ apptime:-
146
+
147
+ vhost:localhost:8888
148
+
149
+ reqtime_human:1.895431ms
150
+
151
+ x-request-id: host:localhost:8888
152
+
153
+ ```
154
+
155
+
156
+
157
+ 下記はかなり見辛いログですが,載せておきます.
158
+
159
+
160
+
161
+ ``` log
162
+
163
+ {"time":"2019-07-26T15:37:53.480874+09:00","level":"-","prefix":"echo","file":"recover.go","line":"73","message":"[PANIC RECOVER] runtime error: invalid memory address or nil pointer dereference goroutine 50 [running]:\necho/middleware.RecoverWithConfig.func1.1.1(0x156b148, 0x1000, 0xc000060000, 0x160b140, 0xc0002b2120)\n\t/Users/kirohi/go/src/echo/middleware/recover.go:71 +0xf1\npanic(0x14cc0e0, 0x195b440)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/runtime/panic.go:522 +0x1b5\ngithub.com/ia17011/subsc/backend/api.UpdateUser.func1(0x160b140, 0xc0002b2120, 0x0, 0x0)\n\t/Users/kirohi/go/src/github.com/ia17011/subsc/backend/api/user.go:74 +0x19d\ngithub.com/labstack/echo.(*Echo).add.func1(0x160b140, 0xc0002b2120, 0xc0002160a0, 0xf)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:505 +0x87\ngithub.com/ia17011/subsc/backend/api/middlewares.serverHeader.func1(0x160b140, 0xc0002b2120, 0x156b148, 0x1000)\n\t/Users/kirohi/go/src/github.com/ia17011/subsc/backend/api/middlewares/mainMiddlewares.go:25 +0x235\necho/middleware.RecoverWithConfig.func1.1(0x160b140, 0xc0002b2120, 0x0, 0x0)\n\t/Users/kirohi/go/src/echo/middleware/recover.go:78 +0xd5\necho/middleware.LoggerWithConfig.func2.1(0x160b140, 0xc0002b2120, 0x3, 0x4)\n\t/Users/kirohi/go/src/echo/middleware/logger.go:119 +0x1c0\ngithub.com/labstack/echo.(*Echo).ServeHTTP(0xc00028a000, 0x15fe860, 0xc0002bc000, 0xc0001e8a00)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:616 +0x22d\nnet/http.serverHandler.ServeHTTP(0xc000226750, 0x15fe860, 0xc0002bc000, 0xc0001e8a00)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2774 +0xa8\nnet/http.(*conn).serve(0xc00021e0a0, 0x15ff560, 0xc0001ecc00)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:1878 +0x851\ncreated by net/http.(*Server).Serve\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2884 +0x2f4\n\ngoroutine 1 [IO wait]:\ninternal/poll.runtime_pollWait(0x1e91ea8, 0x72, 0x0)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/runtime/netpoll.go:182 +0x56\ninternal/poll.(*pollDesc).wait(0xc000232818, 0x72, 0x0, 0x0, 0x154be4a)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/internal/poll/fd_poll_runtime.go:87 +0x9b\ninternal/poll.(*pollDesc).waitRead(...)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/internal/poll/fd_poll_runtime.go:92\ninternal/poll.(*FD).Accept(0xc000232800, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/internal/poll/fd_unix.go:384 +0x1ba\nnet.(*netFD).accept(0xc000232800, 0x30, 0x50, 0x50)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/fd_unix.go:238 +0x42\nnet.(*TCPListener).accept(0xc0002222f8, 0xc0f05880cb, 0xc000088000, 0xc00010dd00)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/tcpsock_posix.go:139 +0x32\nnet.(*TCPListener).AcceptTCP(0xc0002222f8, 0x100000001, 0xc00010dd30, 0x104c368)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/tcpsock.go:247 +0x48\ngithub.com/labstack/echo.tcpKeepAliveListener.Accept(0xc0002222f8, 0xc00010dd58, 0x10afda6, 0x5d3a9fc1, 0x1036bcf)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:820 +0x2f\nnet/http.(*Server).Serve(0xc000226750, 0x15fe4e0, 0xc000222300, 0x0, 0x0)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/net/http/server.go:2859 +0x22d\ngithub.com/labstack/echo.(*Echo).StartServer(0xc00028a000, 0xc000226750, 0x0, 0x0)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:707 +0x388\ngithub.com/labstack/echo.(*Echo).Start(...)\n\t/Users/kirohi/go/src/github.com/labstack/echo/echo.go:627\nmain.main()\n\t/Users/kirohi/go/src/github.com/ia17011/subsc/backend/main.go:16 +0x67\n\ngoroutine 51 [runnable]:\ndatabase/sql.(*DB).connectionOpener(0xc0002ca000, 0x15ff560, 0xc000220300)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/database/sql/sql.go:1000 +0xe8\ncreated by database/sql.OpenDB\n\t/usr/local/Cellar/go/1.12.5/libexec/src/database/sql/sql.go:670 +0x15e\n\ngoroutine 35 [runnable]:\ngithub.com/go-sql-driver/mysql.(*mysqlConn).startWatcher.func1(0xc0001f9080, 0xc0002c6120, 0xc0001f62a0)\n\t/Users/kirohi/go/src/github.com/go-sql-driver/mysql/connection.go:619 +0xbf\ncreated by github.com/go-sql-driver/mysql.(*mysqlConn).startWatcher\n\t/Users/kirohi/go/src/github.com/go-sql-driver/mysql/connection.go:616 +0xbe\n\ngoroutine 52 [runnable]:\ndatabase/sql.(*DB).connectionResetter(0xc0002ca000, 0x15ff560, 0xc000220300)\n\t/usr/local/Cellar/go/1.12.5/libexec/src/database/sql/sql.go:1013 +0x\n"}
164
+
165
+ ```

1

誤字

2019/07/26 06:41

投稿

kioak
kioak

スコア20

test CHANGED
@@ -1 +1 @@
1
- 【Go】echoでのUpdateで500エラーが返り実行できない
1
+ 【Go】echoでのUpdate実装で500エラーが返り実行できない
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- echoでのユーザー情報をUpdateする実装
5
+ echoでのユーザー情報をUpdateする関数の実装
6
6
 
7
7
 
8
8