Hey,
I know this is a very basic question but I am struggeling working my way through the tutorial Call your code from another module - The Go Programming Language . My directory structure looks like this:
- Go
- greetings
- hello
in greetings there is the file greetings.go:
package greetings
import "fmt"
// Hello returns a greeting for the named person.
func Hello(name string) string {
// Return a greeting that embeds the name in a message.
message := fmt.Sprintf("Hi, %v. Welcome!", name)
return message
}
and the corresponding go.mod file.
In hello there is the file hello.go:
package main
import (
"fmt"
"example.com/greetings"
)
func main() {
// Get a greeting message and print it.
message := greetings.Hello("Gladys")
fmt.Println(message)
}
all according to the tutorial. Yet when I try to compile the module hello I get the following error:
example.com/hello imports
example.com/greetings: cannot find module providing package example.com/greetings: unrecognized import path "example.com/greetings": reading https://example.com/greetings?go-get=1: 404 Not Found
Can somebody tell me what I have done wrong? Many thanks!