Created
October 1, 2014 19:19
-
-
Save hourback/28a708f13022413ed616 to your computer and use it in GitHub Desktop.
Trying to create fixture data on line 31-32, but getting . . . "2014/10/01 19:16:02 Creating records
panic: runtime error: index out of range goroutine 1 [running]:
runtime.panic(0x6186e0, 0x8c48f7) /usr/lib/go/src/pkg/runtime/panic.c:266 +0xb6
main.main() /data/docker-ember.js/fanotification/go-net-http/server.go:32 +0x4f9"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
_ "github.com/lib/pq" | |
//"database/sql" | |
//"github.com/jmoiron/sqlx" | |
"log" | |
"io" | |
"net/http" | |
) | |
type Notification struct { | |
Id string | |
Status string | |
DescriptionOfProblem string | |
} | |
func HelloServer(w http.ResponseWriter, req *http.Request) { | |
io.WriteString(w, "hello, world!\n") | |
} | |
func AllNotifications(w http.ResponseWriter, req *http.Request) { | |
io.WriteString(w, "This will list all of the notifications in the database.\n") | |
} | |
func main() { | |
log.Println("Starting server") | |
log.Println("Creating records") | |
people := []Notification{} | |
people[0] = Notification{Id: "1", Status: "OPEN", DescriptionOfProblem: "Blah"} | |
log.Println(people) | |
http.HandleFunc("/hello", HelloServer) | |
http.HandleFunc("/api/notifications", AllNotifications) | |
err := http.ListenAndServe(":8080", nil) | |
if err != nil { | |
log.Fatal("ListenAndServe: ", err) | |
} else { | |
log.Println("Listening on 8080") | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment