I am new to Go and I am trying to make a program that shows the current time and some other stuff:
// A terrible program.
package main
import (
"fmt"
"time"
)
// greeting returns a greeting with some info.
func greeting() string {
return "Hello flat world, the time is: " + time.Now().String()
}
func main() {
hotelName := "Trivag"
hotelName += "o"
fmt.Println(greeting())
fmt.Println("Hotel: " + hotelName)
}
When I try running it with go run
, it shows an import cycle error:
import cycle not allowed
package main
imports fmt
imports errors
imports runtime
imports internal/bytealg
imports internal/cpu
imports runtime
These are my Go environment variables from go env
:
GOARCH="amd64"
GOBIN="amd64"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/dullgo/go"
GORACE=""
GOROOT="/home/dullgo/.local/go"
GOTOOLDIR="/home/dullgo/.local/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
Edit: The .go file was placed directly in the ~/go directory.
That error message seems wrong: the import cycle not allowed
message is supposed to begin and end with the same package path.
Please file an issue by filling out the template at https://golang.org/issue/new.