Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: nil pointer interface. #40

Closed
oytunistrator opened this issue Feb 12, 2019 · 1 comment
Closed

Bug: nil pointer interface. #40

oytunistrator opened this issue Feb 12, 2019 · 1 comment

Comments

@oytunistrator
Copy link

oytunistrator commented Feb 12, 2019

I take nil pointer interface in Mac OS X:

installation:

$ go get -v github.com/zserge/lorca
github.com/zserge/lorca (download)
Fetching https://golang.org/x/net/websocket?go-get=1
Parsing meta tags from https://golang.org/x/net/websocket?go-get=1 (status code 200)
get "golang.org/x/net/websocket": found meta tag get.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at h
ttps:https://golang.org/x/net/websocket?go-get=1
get "golang.org/x/net/websocket": verifying non-authoritative meta tag
Fetching https://golang.org/x/net?go-get=1
Parsing meta tags from https://golang.org/x/net?go-get=1 (status code 200)
golang.org/x/net (download)
golang.org/x/net/websocket
github.com/zserge/lorca

sample code:

package main

import (
        "fmt"
	"github.com/zserge/lorca"
)

func main() {
	ui, _ := lorca.New("", "", 480, 320)  # <---- ui is nil pointer interface!
	fmt.Printf("%v\n", ui) 
	defer ui.Close()
}

result:

$ go run -v testcase8.go
command-line-arguments
<nil>
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x12b0c09]

goroutine 1 [running]:
main.main()
        /test/testcase8.go:15 +0xd9
exit status 2
@kunalpowar
Copy link
Contributor

kunalpowar commented Feb 13, 2019

You should handle the err returned by lorca.New. The error will tell you why it could not create a UI in the first place.

ui, err := lorca.New("", "", 480, 320)
if err != nil {
	log.Fatal(err)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants