Null reference exception with go web server

Hi,

WebServerConsoleApplication.zip (3.2 MB)

If I run the attached and do a curl http://localhost:8080

I get a nullreference exception

Having changed the package to main, using go to run the same piece of code returns a response.

Cheers,
John

One more thing. AssembyInfo is swift, is it meant to be that way ?

Yes, because Go has no syntax for attributes (maybe we’ll add an extension, maybe we wait if Go adds them itself), so we opted for Swift, as that will compile for everybody, needing a non-Go language license (opposed to using Oxygene, C# or Java).

ie just changing package WebServerConsoleApplication to package main fixes it?

No I had to change the package name to main so that I could run using native go.

What I meant was that it works with go but not go.dll.

The other question I had was if I have a single language license that runs out at the end of year, how would I upgrade it to the full elements license ? I want to add a go license and it looks like its the same price as the full elements one, so I may as well just go with that.

Hmm. I’ll leave that to Carlo or Diego.

yeah, you can just renew to full Elements, that’ll add a fresh new year to e=the end of your current license.

Hi, please, modify the handler function like:

func handler(w http.ResponseWriter, r *http.Request) {
    w.Header().Set("Content-Type", "text/plain")
    fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
}

Will investigate the issue omiting the content-type.

1 Like