Original post

Hello,

I’ve started to learn about modules and I’ve started with a simple Echo web server.

// main.go
package main

import (
        "net/http"

        "github.com/labstack/echo"
)

func main() {
        e := echo.New()
        e.GET("/", func(c echo.Context) error {
                return c.String(http.StatusOK, "Hello, World!")
        })
        e.Logger.Fatal(e.Start(":1323"))
}

Using go get -u github.com/labstack/echo/... , I can run the above code from within my GOPATH and a server starts with version 4.1.13.

I have created a new folder for Go modules called /gomodules, which is outside my GOPATH. Inside /gomodules I created a folder called /echo (/gomodules/echo).

Inside /echo I created a go.mod file:

// go.mod
module testing.com/main

go 1.13

I also copied the main.go file into the /echo folder.

When I run main.go, Go gets v3.3.10 of Echo. I had expected it to get the latest version. Here is the result.

module testing.com/main

go 1.13

require (
        github.com/labstack/echo v3.3.10+incompatible // indirect
        github.com/labstack/gommon v0.3.0 // indirect
        .org/x/crypto v0.0.0-20200108215511-5d647ca15757 // indirect
)

I’ve tried manually setting the mod.go file.

module testing.com/main

go 1.13

require (
        github.com/labstack/echo v4.1.13 // indirect
)

As well as:

module testing.com/main

go 1.13

require (
        github.com/labstack/echo/v4 v4.1.13 // indirect
)

The later will run but the first wont. Even after the later runs and the go.mod file looks the same, when running main.go, I am stuck with v3.3.10.

I’ve read the docs on modules and I feel lost as to how to get this to work. What am I missing?

Thanks!