Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gee-orm/day3-save-query/session/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
// Insert one or more records in database
func (s *Session) Insert(values ...interface{}) (int64, error) {
recordValues := make([]interface{}, 0)
table := s.Model(values[0]).RefTable()
s.clause.Set(clause.INSERT, table.Name, table.FieldNames)
for _, value := range values {
table := s.Model(value).RefTable()
s.clause.Set(clause.INSERT, table.Name, table.FieldNames)
recordValues = append(recordValues, table.RecordValues(value))
}

Expand Down
1 change: 0 additions & 1 deletion gee-orm/day5-hooks/session/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ func (s *Session) CallMethod(method string, value interface{}) {
}
}
}
return
}
25 changes: 20 additions & 5 deletions gee-web/day7-panic-recover/gee/recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,30 @@ import (

// print stack trace for debug
func trace(message string) string {
// Allocate an array to store program counters
var pcs [32]uintptr
n := runtime.Callers(3, pcs[:]) // skip first 3 caller
// Get call stack info, skip first 3 callers
n := runtime.Callers(3, pcs[:])

var str strings.Builder
str.WriteString(message + "\nTraceback:")
for _, pc := range pcs[:n] {
fn := runtime.FuncForPC(pc)
file, line := fn.FileLine(pc)
str.WriteString(fmt.Sprintf("\n\t%s:%d", file, line))

// Create Frames object
frames := runtime.CallersFrames(pcs[:n])
for {
// Get one frame per iteration
frame, more := frames.Next()

// Add file, line number and function name
str.WriteString(fmt.Sprintf("\n\t%s:%d - %s",
frame.File,
frame.Line,
frame.Function,
))

if !more {
break
}
}
return str.String()
}
Expand Down