Compare commits
No commits in common. "b860e1acb675f150969c5ffd90816e604e09a6f2" and "5be2d2fd7a47a4a11658c5e6f708bb8577270592" have entirely different histories.
b860e1acb6
...
5be2d2fd7a
4 changed files with 4 additions and 28 deletions
10
go/l19/l1.go
10
go/l19/l1.go
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type User struct{
|
type User struct{
|
||||||
|
|
@ -27,15 +26,6 @@ func handle(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w,"no", http.StatusBadRequest)
|
http.Error(w,"no", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
CheckEmail := strings.ContainsAny(data.Email, "@.")
|
|
||||||
if CheckEmail != true {
|
|
||||||
http.Error(w, "incorrect email", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if data.Age > 150 {
|
|
||||||
http.Error(w, "old", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
|
|
||||||
setChan <- data
|
setChan <- data
|
||||||
|
|
|
||||||
22
go/l19/l2.go
22
go/l19/l2.go
|
|
@ -15,25 +15,11 @@ type UserStruct struct{
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func polz() (int, string, string) {
|
|
||||||
fmt.Printf("Your age? ")
|
|
||||||
var age int
|
|
||||||
fmt.Scan(&age)
|
|
||||||
fmt.Printf("Your name? ")
|
|
||||||
var name string
|
|
||||||
fmt.Scan(&name)
|
|
||||||
fmt.Printf("Your email? ")
|
|
||||||
var email string
|
|
||||||
fmt.Scan(&email)
|
|
||||||
return age, name, email
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
age, name, email := polz()
|
|
||||||
user := UserStruct{
|
user := UserStruct{
|
||||||
Age: age,
|
Age: 66,
|
||||||
Name: name,
|
Name: "Sergey",
|
||||||
Email: email,
|
Email: "Likhodeev.60@mail.ru",
|
||||||
}
|
}
|
||||||
JsonData, err := json.Marshal(user)
|
JsonData, err := json.Marshal(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -56,4 +42,4 @@ func main() {
|
||||||
}
|
}
|
||||||
fmt.Printf("status code %d\n", resp.StatusCode)
|
fmt.Printf("status code %d\n", resp.StatusCode)
|
||||||
fmt.Println(string(body))
|
fmt.Println(string(body))
|
||||||
}
|
}
|
||||||
BIN
go/l19/output/l1
BIN
go/l19/output/l1
Binary file not shown.
BIN
go/l19/output/l2
BIN
go/l19/output/l2
Binary file not shown.
Loading…
Reference in a new issue