code: func rewriteOptionalMethods(decl ast.Decl, isOptional OptionalFunc) {
  	switch t := decl.(type) {
  	case *ast.FuncDecl:
  		ident, ptr, ok := receiver(t)
  		if !ok {
  			return
  		}
  
  		// correct initialization of the form `m.Field = &OptionalType{}` to
  		// `m.Field = OptionalType{}`
  		if t.Name.Name == "Unmarshal" {
  			ast.Walk(optionalAssignmentVisitor{fn: isOptional}, t.Body)
  		}
  
  		if !isOptional(ident.Name) {
  			return
  		}
  
  		switch t.Name.Name {
  		case "Unmarshal":
  			ast.Walk(&optionalItemsVisitor{}, t.Body)
  		case "MarshalTo", "Size", "String":
  			ast.Walk(&optionalItemsVisitor{}, t.Body)
  			fallthrough
  		case "Marshal":
  			// if the method has a pointer receiver, set it back to a normal receiver
  			if ptr {
  				t.Recv.List[0].Type = ident
  			}
  		}
  	}
  }
docs: // rewriteOptionalMethods makes specific mutations to marshaller methods that belong to types identified
  // as being "optional" (they may be nil on the wire). This allows protobuf to serialize a map or slice and
  // properly discriminate between empty and nil (which is not possible in protobuf).
  // TODO: move into upstream gogo-protobuf once https://github.com/gogo/protobuf/issues/181
  //   has agreement