Update generator.go

fix nil panic