Skip to content

Instantly share code, notes, and snippets.

@btoews
Last active April 22, 2016 17:56
Show Gist options
  • Save btoews/e500ea0ff320fc4049f8c598ab426118 to your computer and use it in GitHub Desktop.
Save btoews/e500ea0ff320fc4049f8c598ab426118 to your computer and use it in GitHub Desktop.
error demo
package main
import (
"crypto/sha256"
"fmt"
"hash"
)
type Signer struct {
hash.Hash
}
func (s Signer) InitHash() {
s.Hash = sha256.New()
}
func main() {
s := new(Signer)
s.InitHash()
digest := s.Sum([]byte("hello world"))
fmt.Printf("digest: %x\n", digest)
}
Benjamins-MacBook-Pro:test mastahyeti$ go run ./foo.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x38 pc=0x2139]
goroutine 1 [running]:
panic(0xdf700, 0xc82000a0c0)
/usr/local/Cellar/go/1.6.1/libexec/src/runtime/panic.go:464 +0x3e6
main.main()
/Users/mastahyeti/Projects/go/src/test/foo.go:21 +0xc9
exit status 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment