Merge pull request #1153 from attilanagy/fix_type_in_04_1

Fix the type of request.Form in 04.1
This commit is contained in:
astaxie
2021-01-15 23:20:45 +08:00
committed by GitHub
6 changed files with 14 additions and 14 deletions

View File

@@ -55,7 +55,7 @@ This is easy to find out using the `http` package. Let's see how to handle the f
fmt.Println("password:", r.Form["password"]) fmt.Println("password:", r.Form["password"])
} }
} }
func main() { func main() {
http.HandleFunc("/", sayhelloName) // setting router rule http.HandleFunc("/", sayhelloName) // setting router rule
http.HandleFunc("/login", login) http.HandleFunc("/login", login)
@@ -84,9 +84,9 @@ Try changing the value of the action in the form `http://127.0.0.1:9090/login` t
![](images/4.1.slice.png?raw=true) ![](images/4.1.slice.png?raw=true)
Figure 4.2 Server prints request data Figure 4.2 Server prints request data
The type of `request.Form` is `url.Value`. It saves data with the format `key=value`. The type of `request.Form` is `url.Values`. It saves data with the format `key=value`.
v := url.Values{} v := url.Values{}
v.Set("name", "Ava") v.Set("name", "Ava")

View File

@@ -85,9 +85,9 @@ Try changing the value of the action in the form `http://127.0.0.1:9090/login` t
![](images/4.1.slice.png?raw=true) ![](images/4.1.slice.png?raw=true)
Figure 4.2 Server prints request data Figure 4.2 Server prints request data
The type of `request.Form` is `url.Value`. It saves data with the format `key=value`. The type of `request.Form` is `url.Values`. It saves data with the format `key=value`.
```Go ```Go
v := url.Values{} v := url.Values{}
v.Set("name", "Ava") v.Set("name", "Ava")

View File

@@ -86,7 +86,7 @@ Trata de cambiar la URL de ingreso de `http://127.0.0.1:9090/login` a `http://12
Figure 4.2 Server prints request data Figure 4.2 Server prints request data
El tipo de `request.Form` es `url.Value`. Y lo guarda en el formato `llave=valor`. El tipo de `request.Form` es `url.Values`. Y lo guarda en el formato `llave=valor`.
``` ```
v := url.Values{} v := url.Values{}
v.Set("name", "Ava") v.Set("name", "Ava")

View File

@@ -55,7 +55,7 @@ This is easy to find out using the `http` package. Let's see how to handle the f
fmt.Println("password:", r.Form["password"]) fmt.Println("password:", r.Form["password"])
} }
} }
func main() { func main() {
http.HandleFunc("/", sayhelloName) // setting router rule http.HandleFunc("/", sayhelloName) // setting router rule
http.HandleFunc("/login", login) http.HandleFunc("/login", login)
@@ -84,9 +84,9 @@ Try changing the value of the action in the form `http://127.0.0.1:9090/login` t
![](images/4.1.slice.png?raw=true) ![](images/4.1.slice.png?raw=true)
Figure 4.2 Server prints request data Figure 4.2 Server prints request data
The type of `request.Form` is `url.Value`. It saves data with the format `key=value`. The type of `request.Form` is `url.Values`. It saves data with the format `key=value`.
v := url.Values{} v := url.Values{}
v.Set("name", "Ava") v.Set("name", "Ava")

View File

@@ -55,7 +55,7 @@
fmt.Println("Пароль:", r.Form["password"]) fmt.Println("Пароль:", r.Form["password"])
} }
} }
func main() { func main() {
http.HandleFunc("/", sayhelloName) // устанавливаем правила маршрутизатора http.HandleFunc("/", sayhelloName) // устанавливаем правила маршрутизатора
http.HandleFunc("/login", login) http.HandleFunc("/login", login)
@@ -84,9 +84,9 @@
![](images/4.1.slice.png?raw=true) ![](images/4.1.slice.png?raw=true)
Рисунок 4.2 Сервер печатает данные запроса Рисунок 4.2 Сервер печатает данные запроса
Тип поля `request.Form` - это `url.Value`. Данные в нем сохраняются в формате `ключ=значение`. Тип поля `request.Form` - это `url.Values`. Данные в нем сохраняются в формате `ключ=значение`.
v := url.Values{} v := url.Values{}
v.Set("name", "Ava") v.Set("name", "Ava")

View File

@@ -85,9 +85,9 @@ Try changing the value of the action in the form `http://127.0.0.1:9090/login` t
![](images/4.1.slice.png?raw=true) ![](images/4.1.slice.png?raw=true)
Figure 4.2 Server prints request data Figure 4.2 Server prints request data
The type of `request.Form` is `url.Value`. It saves data with the format `key=value`. The type of `request.Form` is `url.Values`. It saves data with the format `key=value`.
```Go ```Go
v := url.Values{} v := url.Values{}
v.Set("name", "Ava") v.Set("name", "Ava")