gopatch icon indicating copy to clipboard operation
gopatch copied to clipboard

Understand decl groupings

Open abhinav opened this issue 3 years ago • 4 comments

For gopatch, currently the following are different:

var foo = 42

var (
  foo = 42
)

gopatch should understand decl groupings for types, consts, vars, and funcs so that these are treated as equivalent.

Ideally it should also understand which of those groupings are unordered so the following are considered equivalent by a patch.

type (
  Foo struct{}
  Bar struct{}
)

type (
  Bar struct{}
  Foo struct{}
)

abhinav avatar Apr 21 '21 18:04 abhinav

Ideally it should also understand which of those groupings are unordered so the following are considered equivalent by a patch.

@abhinav, did you mean to say these are considered equivalent:

type (
  Foo struct{}
  Bar struct{}
)

type (
  Bar struct{}
  Foo struct{}
)

instead of:

type (
  Foo struct{}
  Bar struct{}
)

type (
  Foo struct{}
  Bar struct{}
)

sywhang avatar Jun 17 '21 22:06 sywhang

Hey @sywhang. Yeah, I meant the first case, but what's different between the two versions in the second case?

abhinav avatar Jun 22 '21 02:06 abhinav

The second struct has "Bar" before "Foo" whereas the example structs in the issue are completely identical structs 😁

sywhang avatar Jun 22 '21 02:06 sywhang

Derp. My bad. Fixing.

abhinav avatar Jun 22 '21 15:06 abhinav