-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add go todo app task #7
Conversation
func Connect() (*gorm.DB, error) { | ||
db, err := gorm.Open("mysql", "root@/go-todo-app?charset=utf8&parseTime=True&loc=Local") | ||
|
||
db.SingularTable(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before use db
here, please check err
first. db
could be nil if gorm.Open
returns error.
Then db.SingularTable(true)
can cause panic error if db
is nil
Go: panic: runtime error: invalid memory address or nil pointer dereference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've added err
check here https://github.com/bali-gophers/backpack/pull/7/files#diff-d15b797a03ae0fe42442c4308adfd7d4R11
} | ||
|
||
func Create(response http.ResponseWriter, request *http.Request) { | ||
taskModel, err := decode(request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before use taskModel, please check err first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added err
check here https://github.com/bali-gophers/backpack/pull/7/files#diff-47328041993fa3e8acb14f43b8f08bb1R35
Hi @rakateja , PR updated :) |
Hi @gusdecool, i'm sorry, just realised ur changes 🙇 🙇 |
issue: #3
sample to-do-app using go language