anonymous func issue 匿名函数不执行 #1316

Closed
opened 2019-06-04 12:58:59 +00:00 by fengjihua · 1 comment
fengjihua commented 2019-06-04 12:58:59 +00:00 (Migrated from github.com)
go func(objThread *model.Thread) {
				conn := common.Config.DB.MySQL
				engine, err := xorm.NewEngine("mysql", conn)
				if err != nil {
					panic(err)
				}

				println("Ready")
				row, err := engine.Insert(objThread)
				println(row)
				println(err)
				println("Done")
}(objThread)

Output:

Ready

engine.Insert() even does not work, no 'row' or 'err' return. SOS!

``` go func(objThread *model.Thread) { conn := common.Config.DB.MySQL engine, err := xorm.NewEngine("mysql", conn) if err != nil { panic(err) } println("Ready") row, err := engine.Insert(objThread) println(row) println(err) println("Done") }(objThread) ``` Output: > Ready engine.Insert() even does not work, no 'row' or 'err' return. SOS!

You should not exit the go routine util the println finished it's work.

You should not exit the go routine util the `println` finished it's work.
lunny closed this issue 2020-06-04 01:51:16 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1316
No description provided.