On Saturday, December 29, 2018 at 10:02:55 PM UTC-6, Andrey Savchuk wrote: > > I'm a beginner in Golang and quite confusing about using packages in a > program. For example, every non simple software has a bunch of classes and > interfaces or utility classes which are usually lokated in different > packages in the same program. So using them in Java fo example makes no > diffculty at all, but it seems Golang makes this diffculty then it comes > for using packages. When classes(structures, methods) are placed in > different packages we should import them and then using them with the > package name like "utility.MyStructure" or "model.DemoStruct" - is not it > an overhead using every time package names when referencing structures of > methods from different packages of the same program? >
There's no overhead; it is compiled to static calls/jumps. (If it helps, the *only* time dynamic dispatch is ever involved is when calling through an interface.) The extra clarity, lack of ambiguity, and ease of reading the package prefixes actually make this key, celebrated feature. That said you can "dot import" if you really have to. This is heavily discouraged of course. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.