#http://localhost:8080/view/test not working

11 messages · Page 1 of 1 (latest)

sage steppe
#

log:

2023/02/12 16:17:04 http: panic serving [::1]:50230: runtime error: invalid memory address or nil pointer dereference
goroutine 6 [running]:
net/http.(*conn).serve.func1()
C:/Program Files/Go/src/net/http/server.go:1850 +0xbf
panic({0x669c80, 0x875ae0})
C:/Program Files/Go/src/runtime/panic.go:890 +0x262
main.viewHandler({0x7194a8?, 0xc0000b6000}, 0x4dec5a?)
C:/Github/Go/main.go:32 +0x76
net/http.HandlerFunc.ServeHTTP(0xc000069af0?, {0x7194a8?, 0xc0000b6000?}, 0x0?)
C:/Program Files/Go/src/net/http/server.go:2109 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0x7194a8, 0xc0000b6000}, 0xc000098000)
C:/Program Files/Go/src/net/http/server.go:2487 +0x149
net/http.serverHandler.ServeHTTP({0xc000088030?}, {0x7194a8, 0xc0000b6000}, 0xc000098000)
C:/Program Files/Go/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc000000be0, {0x719880, 0xc00007f0b0})
C:/Program Files/Go/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
C:/Program Files/Go/src/net/http/server.go:3102 +0x4db

#

http://localhost:8080/ kinda works

#

also previous examples in this tutorial worked perfectly

#

(2 examples:
https://go.dev/doc/articles/wiki/part1.go
and

package main

import (
    "fmt"
    "log"
    "net/http"
)

func handler(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
}

func main() {
    http.HandleFunc("/", handler)
    log.Fatal(http.ListenAndServe(":8080", nil))
}```
#

I allowed it @ firewall

#

so it should work.. as previous example worked

#

(Windows 11 OS x64)

#

I've created file text.txt

#

it's got inside