What does the dot (.) mean in the import statement in Go?
Hello! I recently started learning Go and came across an unclear construct. In some code examples, I see a dot before the package name in the `import` statement. For example:
```go
import (
. "fmt"
)
func main() {
Println("Hello, world!")
}
```
Note that I'm calling `Println` without the `fmt.` prefix. Usually I write `fmt.Println(...)`. But here the dot in the import changes the behavior.
I've also seen similar code with a dot in tests, but I don't understand why it's needed. Is it some kind of magic? When should it be used, and when not? Doesn't it break code readability?
Please explain what the dot does in `import` in Go, and provide examples of when it might be useful. Thanks in advance!
No answers yet.
Log in to leave an answer