-
Notifications
You must be signed in to change notification settings - Fork 0
Homework8 #8
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
base: master
Are you sure you want to change the base?
Conversation
lesson_8/cmd/User/User.go
Outdated
| @@ -0,0 +1,7 @@ | |||
| package User | |||
|
|
|||
| type Struct struct { | |||
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.
strange name of struct
lesson_8/cmd/User/User.go
Outdated
| Token string `json:"token"` | ||
| CurrentDate string `json:"current_date"` | ||
| ExpireAt string `json:"expire_at"` | ||
| } No newline at end of file |
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.
You shouldn't expose this struct in separate package. If you want using structure like this, you should make it in all your services.
| @@ -0,0 +1,46 @@ | |||
| package main | |||
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.
you shouldn't add compiled files to git. (remove compiled files)
lesson_8/cmd/main_server/main.go
Outdated
| func PostToStore(token string, name string, address string) { | ||
| curUser := User.Struct{Token: token, CurrentDate: time.Now().String(), | ||
| ExpireAt: time.Now().AddDate(0, 0, 10).String()} | ||
| mapUser := map[string]User.Struct{name + " " + address: curUser} |
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.
You don't need use map there - you can marshal your user struct and add it in request body
| } | ||
|
|
||
| var res map[string]User.Struct | ||
| json.NewDecoder(r.Body).Decode(&res) |
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.
unmarshal body in user struct directly. Then add it to map
| "../User" | ||
| ) | ||
|
|
||
| var Users []map[string]User.Struct |
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.
you don't need array of maps. You need only one to save your user tokens
| @@ -0,0 +1,3 @@ | |||
| FROM scratch | |||
| ADD main / | |||
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.
automate building application in docker.
| @@ -0,0 +1,3 @@ | |||
| FROM scratch | |||
| ADD main / | |||
| CMD ["/main"] No newline at end of file | |||
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.
automate building application in docker.
No description provided.