diff --git a/015_understanding-TCP-servers/06_dial-write/README.md b/015_understanding-TCP-servers/06_dial-write/README.md
index 3d836a76..5e9cdb6f 100644
--- a/015_understanding-TCP-servers/06_dial-write/README.md
+++ b/015_understanding-TCP-servers/06_dial-write/README.md
@@ -1,3 +1,3 @@
run "02_read-scanner"
-run "07_dial-write"
\ No newline at end of file
+run "06_dial-write"
\ No newline at end of file
diff --git a/022_hands-on/02/04_solution/main.go b/022_hands-on/02/04_solution/main.go
index 7740f10b..2fdb743c 100644
--- a/022_hands-on/02/04_solution/main.go
+++ b/022_hands-on/02/04_solution/main.go
@@ -34,7 +34,5 @@ func main() {
// how does the above reader know when it's done?
fmt.Println("Code got here.")
io.WriteString(conn, "I see you connected.")
-
- conn.Close()
}
}
diff --git a/022_hands-on/02/11_hands-on/README.md b/022_hands-on/02/11_hands-on/README.md
index 64aaf71c..044f91eb 100644
--- a/022_hands-on/02/11_hands-on/README.md
+++ b/022_hands-on/02/11_hands-on/README.md
@@ -1,6 +1,6 @@
# Building upon the code from the previous problem:
-Before we WRITE our RESPONSE , let's WRITE to our RESPONSE the STATUS LINE and some REPONSE HEADERS. Remember the request line and status line:
+Before we WRITE our RESPONSE, let's WRITE to our RESPONSE the STATUS LINE and some RESPONSE HEADERS. Remember the request line and status line:
REQUEST LINE
GET / HTTP/1.1
@@ -22,4 +22,4 @@ fmt.Fprint(c, "Content-Type: text/plain\r\n")
"\r\n"
-Look in your browser "developer tools" under the network tab. Compare the RESPONSE HEADERS from the previous file with the RESPONSE HEADERS in your new solution.
\ No newline at end of file
+Look in your browser "developer tools" under the network tab. Compare the RESPONSE HEADERS from the previous file with the RESPONSE HEADERS in your new solution.
diff --git a/023_serving-files/02_serving/04_FileServer/01/main.go b/023_serving-files/02_serving/04_FileServer/01/main.go
index 5ff93afd..34a0df2a 100644
--- a/023_serving-files/02_serving/04_FileServer/01/main.go
+++ b/023_serving-files/02_serving/04_FileServer/01/main.go
@@ -7,11 +7,11 @@ import (
func main() {
http.Handle("/", http.FileServer(http.Dir(".")))
- http.HandleFunc("/dog", dog)
+ http.HandleFunc("/dog/", dog)
http.ListenAndServe(":8080", nil)
}
func dog(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
- io.WriteString(w, `
`)
+ io.WriteString(w, `
`)
}
diff --git a/024_hands-on/12_solution/main.go b/024_hands-on/12_solution/main.go
index 8f8bf128..7e59a3e7 100644
--- a/024_hands-on/12_solution/main.go
+++ b/024_hands-on/12_solution/main.go
@@ -14,8 +14,8 @@ func init() {
func main() {
http.HandleFunc("/", index)
- http.HandleFunc("/about", about)
- http.HandleFunc("/contact", contact)
+ http.HandleFunc("/about/", about)
+ http.HandleFunc("/contact/", contact)
http.HandleFunc("/apply", apply)
http.ListenAndServe(":8080", nil)
}
diff --git a/026_appengine-deploy/01/app.yaml b/026_appengine-deploy/01/app.yaml
index 1dd8f1c6..fb82ec67 100644
--- a/026_appengine-deploy/01/app.yaml
+++ b/026_appengine-deploy/01/app.yaml
@@ -1,8 +1,6 @@
-application: temp-145415
-version: 1
-runtime: go
-api_version: go1
+runtime: go113
handlers:
- url: /.*
- script: _go_app
\ No newline at end of file
+ script: auto
+ secure: always
\ No newline at end of file
diff --git a/026_appengine-deploy/01/main.go b/026_appengine-deploy/01/main.go
index 68523458..671d6b1d 100644
--- a/026_appengine-deploy/01/main.go
+++ b/026_appengine-deploy/01/main.go
@@ -4,6 +4,7 @@ import (
"net/http"
)
-func init() {
+func main() {
http.Handle("/", http.FileServer(http.Dir(".")))
+ http.ListenAndServe(":8080", nil)
}
diff --git a/026_appengine-deploy/02/app.yaml b/026_appengine-deploy/02/app.yaml
index 1dd8f1c6..fb82ec67 100644
--- a/026_appengine-deploy/02/app.yaml
+++ b/026_appengine-deploy/02/app.yaml
@@ -1,8 +1,6 @@
-application: temp-145415
-version: 1
-runtime: go
-api_version: go1
+runtime: go113
handlers:
- url: /.*
- script: _go_app
\ No newline at end of file
+ script: auto
+ secure: always
\ No newline at end of file
diff --git a/026_appengine-deploy/02/main.go b/026_appengine-deploy/02/main.go
index 68523458..671d6b1d 100644
--- a/026_appengine-deploy/02/main.go
+++ b/026_appengine-deploy/02/main.go
@@ -4,6 +4,7 @@ import (
"net/http"
)
-func init() {
+func main() {
http.Handle("/", http.FileServer(http.Dir(".")))
+ http.ListenAndServe(":8080", nil)
}
diff --git a/026_appengine-deploy/README.md b/026_appengine-deploy/README.md
index 247ba1be..c256d787 100644
--- a/026_appengine-deploy/README.md
+++ b/026_appengine-deploy/README.md
@@ -1,30 +1,27 @@
-# buying a domain
+ # buying a domain
https://domains.google/#/
# deploying to [Google Cloud](https://cloud.google.com/)
- [install google appengine](https://cloud.google.com/appengine/docs/go/download)
-- [make sure python is installed VERSION 2.7.x](https://www.python.org/downloads/release/python-2712/)
- - python -V
- configure environment PATH variables
- google cloud developer console
- create a project
- get the project ID
-- update the app.yaml file with your project ID
+- set your go version in the app.yaml file
```
-application: temp-137512
-version: 1
-runtime: go
-api_version: go1
-
+runtime: go113
handlers:
- url: /.*
- script: _go_app
+ script: auto
+ secure: always
```
-- deploy to that project
+- deploy to that project. update --project with your project-id
```
-appcfg.py -A -V v1 update .
+gcloud app deploy app.yaml --project= -v 1
+my example:
+gcloud app deploy --project temp-137512
```
- view your project
- http://YOUR_PROJECT_ID.appspot.com/
diff --git a/030_sessions/03_signup/main.go b/030_sessions/03_signup/main.go
index a1da2c8d..48f0d58c 100644
--- a/030_sessions/03_signup/main.go
+++ b/030_sessions/03_signup/main.go
@@ -1,9 +1,10 @@
package main
import (
- "github.com/satori/go.uuid"
"html/template"
"net/http"
+
+ uuid "github.com/satori/go.uuid"
)
type user struct {
@@ -30,12 +31,12 @@ func main() {
}
func index(w http.ResponseWriter, req *http.Request) {
- u := getUser(w, req)
+ u := getUser(req)
tpl.ExecuteTemplate(w, "index.gohtml", u)
}
func bar(w http.ResponseWriter, req *http.Request) {
- u := getUser(w, req)
+ u := getUser(req)
if !alreadyLoggedIn(req) {
http.Redirect(w, req, "/", http.StatusSeeOther)
return
diff --git a/030_sessions/03_signup/session.go b/030_sessions/03_signup/session.go
index 17a72572..bda111e9 100644
--- a/030_sessions/03_signup/session.go
+++ b/030_sessions/03_signup/session.go
@@ -2,26 +2,18 @@ package main
import (
"net/http"
-
- "github.com/satori/go.uuid"
)
-func getUser(w http.ResponseWriter, req *http.Request) user {
+func getUser(req *http.Request) user {
+ var u user
+
// get cookie
c, err := req.Cookie("session")
if err != nil {
- sID, _ := uuid.NewV4()
- c = &http.Cookie{
- Name: "session",
- Value: sID.String(),
- }
-
+ return u
}
- //Next line may not be required, commenting it
- // http.SetCookie(w, c)
// if the user exists already, get user
- var u user
if un, ok := dbSessions[c.Value]; ok {
u = dbUsers[un]
}