rlp/rlpgen: fix error handling when target type not found (#25547)

typ will be nil when lookupStructType returns an error. cfg.Type should be used instead.
pull/25545/head^2
Justin Traglia 2 years ago committed by GitHub
parent 23ac8df153
commit cce7f08438
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      rlp/rlpgen/main.go

@ -106,7 +106,7 @@ func (cfg *Config) process() (code []byte, err error) {
// Find the type and generate. // Find the type and generate.
typ, err := lookupStructType(pkg.Scope(), cfg.Type) typ, err := lookupStructType(pkg.Scope(), cfg.Type)
if err != nil { if err != nil {
return nil, fmt.Errorf("can't find %s in %s: %v", typ, pkg, err) return nil, fmt.Errorf("can't find %s in %s: %v", cfg.Type, pkg, err)
} }
code, err = bctx.generate(typ, cfg.GenerateEncoder, cfg.GenerateDecoder) code, err = bctx.generate(typ, cfg.GenerateEncoder, cfg.GenerateDecoder)
if err != nil { if err != nil {

Loading…
Cancel
Save