metal3d / goreorder

Reorder methods, constructors and structs in Go files
6 stars 1 forks source link

type definition ordering strangeness #13

Open andydotxyz opened 1 year ago

andydotxyz commented 1 year ago

Applying the latest version in Fyne's geometry.go I see the following order of public types:

type Delta struct
type Position struct
type Size struct
func NewDelta(dx float32, dy float32) Delta
func NewPos(x float32, y float32) Position
func NewSize(w float32, h float32) Size
type Vector2 interface

After this the type methods are added. I'm not totally sure, but this seems not quite right...

andydotxyz commented 1 year ago

Another strange thing in canvas/image.go the type definition order is right but the const order seems backwards:

type ImageFill int
type ImageScale int32

const (
    ImageScaleSmooth ImageScale = iota
...
)

const (
    ImageFillStretch ImageFill = iota
...
)
andydotxyz commented 1 year ago

Lastly in layout/boxlayout we can see constructor functions returning a more generic type appear last:

func (g *boxLayout) isSpacer(obj fyne.CanvasObject) bool {
...
}

func NewHBoxLayout() fyne.Layout
func NewVBoxLayout() fyne.Layout
metal3d commented 1 year ago

I will take a look as soon as I can - Fyne is a great source base to make this kind of tests.