Hi, here is the problem:
I did refactor the code of my project and moved a specific functionality to a local package.
But now I’m encountering problems importing remote GitHub packages from that package.
Here is the structure om my project (it placed just “somewhere”):
login_watch
│ build4linux.cmd
│ Dockerfile
│ go.mod
│ go.sum
│ main.go
│
├───bin
├───log
└───pkg
└───analyzer
series.go
series_test.go
That is, my app is a module named “github.com/mustikkakeitto/login_watch” in the login_watch folder somewhere on the disk, and it has main.go file:
package main
import (
"container/list"
"fmt"
"github.com/mustikkakeitto/login_watch/pkg/analyzer"
"time"
"encoding/json"
"log"
"net/http"
"sync"
"github.com/gorilla/mux"
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
)
// etc
main.go imports the local package as “github.com/mustikkakeitto/login_watch/pkg/analyzer”.
That package, in its turn, imports 3rd-party remote package golang-levenshtein/levenshtein" from the GitHub,
here is the contents of login_watch/pkg/analyzer/series.go:
// Package analyzer implements functions to detect series
// built from the particular phone numbers
package analyzer
import (
"container/list"
"fmt"
"time"
"github.com/texttheater/golang-levenshtein/levenshtein"
"log"
)
// etc
So now, when I start the build / run command, I see this:
go run .
pkg\analyzer\series.go:10:2: cannot find package
I just don’t understand, why the imported library package could not be found?
It worked pretty well, when all the functionality from pkg\analyzer\series.go resided in the \main.go …
Here is my go.mod file, in the root of my project:
module github.com/mustikkakeitto/login_watch
go 1.16
require (
github.com/gorilla/mux v1.8.0
github.com/jonboulle/clockwork v0.2.2 // indirect
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
github.com/lestrrat-go/strftime v1.0.4 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/texttheater/golang-levenshtein/levenshtein v0.0.0-20200805054039-cae8b0eaed6c // indirect
)
And some other info, for the record:
go version go1.16.4 windows/amd64
GOPATH=C:\Users\Alex\go
Environment variable GOROOT not defined
Environment variable GO111MODULE not defined
Any help would be appreciated!