Skip to content
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

Merged
merged 2 commits into from
Jan 12, 2019
Merged

add go todo app task #7

merged 2 commits into from
Jan 12, 2019

Conversation

gusdecool
Copy link
Contributor

issue: #3

sample to-do-app using go language

func Connect() (*gorm.DB, error) {
db, err := gorm.Open("mysql", "root@/go-todo-app?charset=utf8&parseTime=True&loc=Local")

db.SingularTable(true)
Copy link
Contributor

@rakateja rakateja Oct 29, 2018

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

examples/to-do-app/db/migration/migration.go Outdated Show resolved Hide resolved
examples/to-do-app/db/repository/task/task.go Outdated Show resolved Hide resolved
examples/to-do-app/db/repository/task/task.go Outdated Show resolved Hide resolved
examples/to-do-app/db/repository/task/task.go Outdated Show resolved Hide resolved
examples/to-do-app/db/repository/task/task.go Outdated Show resolved Hide resolved
examples/to-do-app/db/repository/task/task.go Outdated Show resolved Hide resolved
}

func Create(response http.ResponseWriter, request *http.Request) {
taskModel, err := decode(request)
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gusdecool
Copy link
Contributor Author

Hi @rakateja , PR updated :)

@rakateja
Copy link
Contributor

rakateja commented Dec 4, 2018

Hi @gusdecool, i'm sorry, just realised ur changes 🙇 🙇

@gusdecool gusdecool merged commit 6e062fb into bali-gophers:master Jan 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants