At package level main
I have 2 files hello.go
and main.go
.
|- hello.go
|- main.go
Both the files are in package main
level but unlike other packages I am unable to import a func
defined in the hello
in the func main
. Can there be only 1 file with package main
?
// hello.go
package main
import "fmt"
func Hello() {
fmt.Println("hello world")
}
// main.go
package main
func main() {
Hello()
}
Error
./main.go:4:2: undefined: Hello
In the terminal, you should use
instead of