#Is a dot-import a bad practice?

21 messages · Page 1 of 1 (latest)

magic tundra
#

yes, quite frankly it’s typically considered bad practice outside of testing code, but if you want to then nobody’s going to stop you 🤷‍♀️

knotty glen
#

one way to solve that is making most of your stuff receivers

#

that way only place it shows is like v := mymath.NewVector() and then it's v.This() v.That()

#

btw... I don't know the syntax... what's dot import looking like (8 years of go, never used it)

#

oh interesting til

#

type aliases are fine, but maybe a smoke that the name of your package is not great

#

vector ?

#

or vect?

#

what's the f2 standing for?

#

fortran 2 ?

#

but you're on the right track, naming is hard... but "better names"

#

oh... that's not great name I think

#

well I was about to say Point but... realized it could be 2d or 3d

#

why not just
type Vector struct {
xi []float64
}
(though maybe you care about memory foot print)

#

PlanePoint vs VolPoint?

#

Plane implies 2 dimensional

#

but maybe just Point (for 2d) and Vector (for 3d)

reef gorge
#

Personally I don’t see a problem with it for some math/vector related stuff. Oftentimes math libraries can be a bit nonidiomatic to make usage and semantics easier. Just make sure to not pollute the namespace too much

lapis juniper
#

If my names conflict with go names I follow my madeup convention of prefixing std packages with go- , works fine for me

#

gocrypto gomath gorand etc

#

Packages like fhttp are nearly 1:1 std ones and they always shadow std packages