# Null reference exception with go web server

**URL:** https://talk.remobjects.com/t/null-reference-exception-with-go-web-server/21357
**Category:** Gold
**Created:** [February 13, 2020, 1:20am UTC](https://talk.remobjects.com/t/null-reference-exception-with-go-web-server/21357 "2020-02-13T01:20:12Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![JohnMoshakis](https://talk.remobjects.com/user_avatar/talk.remobjects.com/johnmoshakis/32/2286_2.png) [@JohnMoshakis](https://talk.remobjects.com/u/JohnMoshakis)
#### Post date: [February 13, 2020, 1:20am UTC](https://talk.remobjects.com/t/null-reference-exception-with-go-web-server/21357/1 "2020-02-13T01:20:13Z")

</div>

Hi,

[WebServerConsoleApplication.zip](https://talk.remobjects.com/uploads/short-url/iaqNDTAouFS7QNaJ8eBoWdYcNNt.zip) (3.2 MB)

If I run the attached and do a curl [http://localhost:8080](http://localhost:8080)

I get a nullreference exception

 ![Screen Shot 2020-02-12 at 8.14.54 PM](https://talk.remobjects.com/uploads/default/original/2X/a/a6d2b82a5eae77c0f61505f78173e4af54bf9b85.jpeg)

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

Cheers,  
John

---

<div class="post-metadata">

### Author: ![JohnMoshakis](https://talk.remobjects.com/user_avatar/talk.remobjects.com/johnmoshakis/32/2286_2.png) [@JohnMoshakis](https://talk.remobjects.com/u/JohnMoshakis)
#### Post date: [February 13, 2020, 4:45pm UTC](https://talk.remobjects.com/t/null-reference-exception-with-go-web-server/21357/2 "2020-02-13T16:45:43Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [February 13, 2020, 6:21pm UTC](https://talk.remobjects.com/t/null-reference-exception-with-go-web-server/21357/3 "2020-02-13T18:21:31Z")

</div>

> [@JohnMoshakis](#):
>
> 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).

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [February 13, 2020, 6:24pm UTC](https://talk.remobjects.com/t/null-reference-exception-with-go-web-server/21357/4 "2020-02-13T18:24:31Z")

</div>

ie just changing `package WebServerConsoleApplication` to `package main` fixes it?

---

<div class="post-metadata">

### Author: ![JohnMoshakis](https://talk.remobjects.com/user_avatar/talk.remobjects.com/johnmoshakis/32/2286_2.png) [@JohnMoshakis](https://talk.remobjects.com/u/JohnMoshakis)
#### Post date: [February 13, 2020, 6:41pm UTC](https://talk.remobjects.com/t/null-reference-exception-with-go-web-server/21357/6 "2020-02-13T18:41:12Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [February 13, 2020, 6:44pm UTC](https://talk.remobjects.com/t/null-reference-exception-with-go-web-server/21357/7 "2020-02-13T18:44:28Z")

</div>

> [@JohnMoshakis](#):
>
> 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.

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

> [@JohnMoshakis](#):
>
> 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.

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

---

<div class="post-metadata">

### Author: ![Diego\_Navarro](https://talk.remobjects.com/user_avatar/talk.remobjects.com/diego_navarro/32/11766_2.png) [@Diego\_Navarro](https://talk.remobjects.com/u/Diego_Navarro)
#### Post date: [February 13, 2020, 7:23pm UTC](https://talk.remobjects.com/t/null-reference-exception-with-go-web-server/21357/8 "2020-02-13T19:23:19Z")

</div>

Hi, please, modify the handler function like:

```auto
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.
