Wrote a simple program for the test:
package main
import (
"fmt"
"github.com/labstack/echo/v4"
)
func main() {
e := echo.New()
fmt.Printf("YEEEEEEES!")
e.Logger.Fatal(e.Start(":1323"))
}
And when go run main.go
it prints YEEEEEEES!
and starts the server :1323.
But after restarting (close and reopen) the terminal (Bach) and re-entering (in the same path) the same command go run main.go
already produces an error:
main.go:4:2: cannot find package "github.com/labstack/echo/v4" in any of:
C:\Program Files\Go\src\github.com\labstack\echo\v4 (from $GOROOT)
C:\Users\lol20\go\src\github.com\labstack\echo\v4 (from $GOPATH)
Assumed that the problem could be in Echo
, but with Iris
the situation was the same.
Checked, the computer has a path C:\Users\lol20\go\src\github.com\labstack\echo
, but no C:\Users\lol20\go\src\github.com\labstack\echo\v4
(difference in \v4 at the end). I suppose this is the problem, because from the error it is clear that the search is performed in the path C:\Users\lol20\go\src\github.com\labstack\echo\v4
.
Please tell me what is the problem and how to fix it(
CodePudding user response:
Try switching GO111MODULE="on"
as follows: go env -w GO111MODULE=on
(switching with export GO111MODULE="on"
only works until the shell environment changes (before restarting the terminal))