Go importing local file

Viewed 26

im struggling to understand how i would import a local .go file into my main.go file
i have got two files

  • main.go
  • mod/hello.go
// main.go go code
package main

import (
    "fmt"
    "mod/hello"
)

func main() {
    fmt.Println("Hello World")
    fmt.Println(hello.greet())
}

// hello.go code 
package hello

func greet() string {
    return "hello!"
}

when ever i tr running the program in it's current state i get the following error imports mod/hello: disallowed import path "mod/hello" how would i resolve this? and how would i import the file?

0 Answers
Related