K
K
KeyDel2019-05-24 08:58:52
go
KeyDel, 2019-05-24 08:58:52

Go build: Can't find package, duplicate src in package search path, what's wrong?

I can't figure out how to connect the package (GO, CentOC).
Structure:
5ce787de6523b961329312.jpegecho $GOPATH/var/www/go/src
In main.go (file path: /var/www/go/src/lesson/main.go) I try to include the models package from the User.go file (file path: /var /www/go/src/lesson/models/User.go)
Content of main.go :

package main
import "lesson/models"

Content of User.go :
package models
Compiler swears: cannot find package "lesson/models" in any of: /var/www/go/ src/src /lesson/models (from $GOPATH)
What's wrong with double src in path? Google is full of various errors related to compilation paths, but I can not find the answer to my question for the second day.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Shatokhin, 2019-05-24
@KeyDel

Inside $GOPATH src, bin, pkg are created. That is, make GOPATH=/var/www/go
In general, tie with $GOPATH and switch to modules

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question