I can't use packages

I’m having problems to use packages. I a following literally the steps I find online, but I have an error message.

I have this package in GOPATH:
go/src/greet/day.go

package greet

var morning = "Good morning"
var Morning = "hey" + morning

I want to import it in my code:
go/src/app/entry.go

package main

import ("fmt"
        "greet")

func main(){
    fmt.Println(greet.Morning)
}

When I run entry.go, I receive this message: entry.go:4:3: package greet is not in GOROOT (/usr/local/go/src/greet)

Does anybody how to fix it?

Thank you.

Modern go does not rely on GOPATH anymore.

Please use proper modules with an appropriate module path.

1 Like