nex-protocols-go icon indicating copy to clipboard operation
nex-protocols-go copied to clipboard

Migrate to new `nex-go` types

Open jonbarrow opened this issue 1 year ago • 0 comments

Resolves #XXX

Changes:

  • Updates all code to use the new nex-go types. See https://github.com/PretendoNetwork/nex-go/pull/56 for details
  • Removes the use of pointers where they shouldn't/can't be used
  • Changes basic variable instancing to use var name type rather than the NewType functions. This is more commonly preferred in Go when a NewType function doesn't do anything special/extra
    • Note: This only happens for basic types from the nex-go changes, any protocol types are still handled using the NewType functions

Marked as a draft for now since these changes are untested. Most done using regex-replace in VSC and some codegen. Some basic servers, not using nex-protocols-common-go, should be made to verify functionality.

I will not be making any changes to nex-protocols-common-go until these changes have been verified to be working.

Since structs are no longer bound to pointer fields now, a few extra changes can possibly be made:

  • NewType functions can now likely just return Type{} rather than instantiating every field. This was done originally to ensure we didn't have any nil pointers, but with the removal of pointers this is no longer a concern

  • The Copy methods on structs can probably be updated to not call Copy internally, rather they can likely just assign the field values directly due to the removal of pointers

  • If the NewType functions are updated to just return Type{} then that means in each RMC handler we can also update any protocol types to use var name type, just like the basic types, rather than using NewType. This would keep things uniform and more Go-like

  • [x] I have read and agreed to the Code of Conduct.

  • [x] I have read and complied with the contributing guidelines.

  • [ ] What I'm implementing was an approved issue.

  • [ ] I have tested all of my changes.

jonbarrow avatar Aug 09 '24 22:08 jonbarrow