The necessity of having package names in a code when the package was declared in import

(cinematik) #1

There definitevly was a reason for having package names in code after those packages were declared in an import block. Let’s explore the following code snippet. The second (commented) variant seems easier.

  • it’s shorter and faster to write it down
  • there is no confusion about what is actually the Appliances - an object or a package

So why had this pattern chosen when the language have been formed?

    package main

    import (

    func main() {
        myAppliance, err := Appliances.CreateAppliance()
        //myAppliance, err := CreateAppliance()

(Norbert Melzer) #2

If at least two of the imported packages have a function Foo which one would you pick if everything is imported unqualified?

If though you want to pollute your local packages namespace you can import (. "fmt").