Permalink
Browse files

Fix #74: gozmqfix panic under go 1.1

This panic actually occurs whenever gozmqfix is applied to a package
that imports gozmq without an alias, and is not 1.1 specific.
  • Loading branch information...
1 parent 9e15b37 commit 414f11c2875b73710b4d9f4f79986fc7a0281b96 @jtacoma jtacoma committed May 16, 2013
Showing with 19 additions and 1 deletion.
  1. +4 −1 gozmqfix/zmqstruct.go
  2. +15 −0 gozmqfix/zmqstruct_test.go
View
@@ -26,7 +26,10 @@ func zmqstruct(f *ast.File) bool {
if spec == nil {
return false
}
- zmq := spec.Name.Name
+ zmq := "gozmq"
+ if spec.Name != nil {
+ zmq = spec.Name.Name
+ }
fixed := false
walk(f, func(n interface{}) {
View
@@ -70,6 +70,21 @@ var GlobalM = newM(c.NewContext(), nil.(*zmq.Socket))
type Socket *zmq.Socket
var S Socket = Socket(M.s)
+`,
+ },
+ {
+ Name: "zmqstruct.1",
+ In: `package main
+
+import "github.com/alecthomas/gozmq"
+
+type Socket *gozmq.Socket
+`,
+ Out: `package main
+
+import "github.com/alecthomas/gozmq"
+
+type Socket *gozmq.Socket
`,
},
}

1 comment on commit 414f11c

Collaborator

jtacoma commented on 414f11c May 16, 2013

Ok, a couple of things I could've done better here: first, I didn't update the fix metadata; second, the new test case includes a type definition in "In" (type Socket *gozmq.Socket) that is already fixed - definitely not what I meant to do.

Please sign in to comment.