Answer the question
In order to leave comments, you need to log in
Why are modules not being imported?
I don't understand how to import modules correctly. Here is a demo I posted:
main.go at the root:
package main
import "./client"
func main() {
client.TestFunc("Test")
}
package client
import (
"fmt"
"github.com/gorilla/websocket"
)
type Client struct {
Name string
conn *websocket.Conn
}
func TestFunc(name string) {
c := &Client{Name: name}
fmt.Printf("%s", c.Name)
}
module test
go 1.14
require github.com/gorilla/websocket v1.4.2
Answer the question
In order to leave comments, you need to log in
import "./client"
You can't do that, the import path is always absolute. If your app's module in go.mod is called test, then the import will be test/client
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question