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

kadai4 yasuno #57

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

kadai4 yasuno #57

wants to merge 3 commits into from

Conversation

yasuno0327
Copy link

@yasuno0327 yasuno0327 commented Dec 2, 2018

概要

● JSON形式でおみくじ結果を返す
● 正月(1/1-1/3)だけ大吉にする
● ハンドラテストを書いてみる

@yasuno0327 yasuno0327 changed the title おみくじAPIを作ってみよう kadai4 yasuno Dec 2, 2018
@yasuno0327 yasuno0327 added the kadai4 課題4 label Dec 2, 2018
newYearsDay := time.Date(2018, 1, 1, 0, 0, 0, 0, location)
endDay := time.Date(2018, 1, 4, 0, 0, 0, 0, location)
if !now.Before(newYearsDay) && !now.After(endDay) {
fortune = "大吉"
Copy link

Choose a reason for hiding this comment

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

else が長く続くならここで return "大吉", nil としたほうがネストが浅くなって良いです

Copy link
Author

Choose a reason for hiding this comment

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

ありがとうございます!

randomInt = rand.Intn(17)
switch randomInt {
case 0:
fortune = "大大吉"
Copy link

Choose a reason for hiding this comment

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

この変数に入れてなにか処理をするとかもないので、さっと return "運勢", nil していいと思います。
default の場合は return "", errors.New(...) となります。

Copy link
Author

Choose a reason for hiding this comment

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

確かにそうですね....
ありがとうございます!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kadai4 課題4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants