3109
219
1662

In the data definitions for this solution, each region has its own title (e.g., 'Northern', 'Central', but the region values are all coded as 'southern' in the data structure. For example:

		region{
			Region: "Northern",
			Hotels: []hotel{
				hotel{
					Name:    "Hotel California",
					Address: "42 Sunset Boulevard",
					City:    "Los Angeles",
					Zip:     "95612",
					Region:  "southern",   <!-- s/b northern -->
				},
				hotel{
					Name:    "H",
					Address: "4",
					City:    "L",
					Zip:     "95612",
					Region:  "southern",  <!-- s/b northern -->
				},
			},
		},

Can anyone Update the code in 44th folder. I'm having trouble in connecting in these three simultaneously. When I try to connect go and html, it works fine. When I try to connect go and postgresql it works fine but doesnt work simultaneously. I get this error when i try curl -i localhost:8080/books after running the go file. Here's th error:
http: panic serving 127.0.0.1:56720: runtime error: invalid memory address or nil pointer dereference follwed by a 2 page of some errors

I keep getting the following error: panic: pq: password authentication failed for user "bond"

I cannot find what's wrong with the code, as it's the one that was used in the course, and in the course it ran perfectly.
Can you find the problem?

GO CODE:

package main

import (
"database/sql"
"fmt"

_ "github.com/lib/pq"

)

func main() {
db, err := sql.Open("postgres", "postgres://bond:password@localhost/bookstore?sslmode=disable")
if err != nil {
panic(err)
}
defer db.Close()

err = db.Ping() //"Ping" checks if a connection to a database is still live, and returns an error if it isnt (so if theres no error it means its connected).
if err != nil {
	panic(err)
}
fmt.Println("You've connected to your database")

}

postgreSQL CODE:

postgres=# CREATE DATABASE bookstore;
CREATE DATABASE
postgres=# CREATE USER bond WITH PASSWORD 'password';
CREATE ROLE
postgres=# GRANT ALL PRIVILEGES ON DATABASE bookstore to bond;
GRANT

When trying to go get or git clone this repo I get the following errors

Cloning into 'C:\GoWorkspace\src\github.com\GoesToEleven\golang-web-dev'...
fatal: early EOF
fatal: the remote end hung up unexpectedly
fatal: index-pack failed
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
package github.com/GoesToEleven/golang-web-dev: exit status 128

I tried to goolge around on this but didn't get very far is it something that can be fixed ay the repo end . Thanks

i have looked this video: https://www.youtube.com/watch?v=qrPWnAZew-E golang interface
it's wonderful.
Can i get more videos about this course?

Is there any way to authenticate using existing cookie and gets details from the API request? I am very new to golang, Also went through the Chapter 29 but couldn't relate to the case I am working on. If you have reading on that can you please point it out?

My Case:
I want to connect to the REST API of remote server via golang. However the authentication to the api is via cookie only. So need to pass the existing cookie information to get authenticated and pull out the details.

Just FYI

body := `<!DOCTYPE html><html lang="en"><head><meta charet="UTF-8"><title></title></head><body><strong>Hello World</strong></body></html>`

Really loving the course by the way! Thanks

Hi Todd,

if I run the code as is then i get this error back on the command line:

# command-line-arguments
./main.go:33:7: undefined: getUser
./main.go:38:7: undefined: getUser
./main.go:39:6: undefined: alreadyLoggedIn
./main.go:47:5: undefined: alreadyLoggedIn

I know you deliberately wanted to keep session.go separate but I can only get this e.g. to work if i copy and paste the 2 funcs "getUser" and "alreadyLoggedIn" and place them in main.go while commenting out session.go completely.

have fun voting today & keep up the good work,

ishwar@warewolf:/crud$ go run main.go

command-line-arguments

./main.go:13:28: undefined: books
./main.go:15:33: undefined: books
./main.go:16:35: undefined: books
./main.go:17:43: undefined: books
./main.go:18:35: undefined: books
./main.go:19:43: undefined: books
./main.go:20:43: undefined: books

The starting-files directory has an index.html file instead of a templates directory with a template in it.

This directory seems like it's missing starting-code

line 24, 25 should be /xxx/. 😄

func main() {
	var d hotdog
	var c hotcat

	http.Handle("/dog/", d)
	http.Handle("/cat/", c)

	http.ListenAndServe(":8080", nil)
}