I'm really new to Go and I'm trying to import a local file in the main.go. This is how the project is structured:
-project_name(dir)
--src(dir)
---main.go
---auth(dir)
----signup.go
I'm trying to use a function I wrote in signup.go
in main.go
.
This is how I tried to import the signup.go
in main.go
:
import (
"encoding/json"
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
auth "./auth"
)
and use it like that:
myRouter.HandleFunc("/signup", auth.signupUser).Methods("POST")
I also tried copying the relative auth dir
and write it in the import but I still get an error undefined: auth go
I tried looking for answers but I can't see what I'm doing differently from the answers I saw.