Echo: Readme seems to be confusing regarding versions

Created on 24 Feb 2019  路  7Comments  路  Source: labstack/echo

Issue Description

As of version 4.0.0, Echo is available as a Go module. Therefore a Go version capable of understanding /vN suffixed imports is required
1.9.7+
1.10.3+
1.11+

That can be undestood as

you can use v4 with go version > 1.9.7

Expected behaviour

import github.com/labstack/echo/v4 using dep actually imports v4 version

Actual behaviour

Solving failure: No versions of github.com/labstack/echo met constraints:
    v4.0.0: Could not introduce github.com/labstack/[email protected], as its subpackage github.com/labstack/echo/v4/middleware is missing. (Package is required by (root).)
    v3.3.10: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.3.9: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.3.8: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.3.7: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.3.6: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.3.5: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    3.3.4: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.3.4: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.3.3: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    3.3.3: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.3.2: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    3.3.2: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    3.3.1: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.3.1: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    3.3.0: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.3.0: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    3.2.6: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.2.6: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.2.5: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    3.2.5: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.2.4: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    3.2.4: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    3.2.3: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.2.3: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.2.2: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    3.2.2: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.2.1: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.2.0: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.1.0: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.0.3: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.0.2: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.0.1: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.0.0: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v2.2.0: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v2.1: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v2.0.2: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v2.0.1: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v2.0.0: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v1.4.4: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v1.4.3: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v1.4.2: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v1.4.1: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v1.4: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v1.3: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v1.2.0: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v1.1.0: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v1.0.0: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v0.0.16: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v0.0.15: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v0.0.14: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v0.0.13: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v0.0.12: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v0.0.11: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v0.0.10: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v0.0.9: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v0.0.8: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v0.0.7: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v0.0.6: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v0.0.5: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v0.0.4: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v0.0.3: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v0.0.2: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.3.8-retag: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.3.7-retag: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.3.6-retag: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.3.5-retag: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.1.0-rc.1: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.0.0-beta.3: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.0.0-beta.2: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v3.0.0-beta.1: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v2.0.0-beta.2: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v2.0.0-beta.1: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v2.0.0-apha1: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v2.0.0-apha.2: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v2.0.0-apha.1: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    2.0.0-alpha: Could not introduce github.com/labstack/[email protected], as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    master: Could not introduce github.com/labstack/echo@master, as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v1: Could not introduce github.com/labstack/echo@v1, as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.
    v2: Could not introduce github.com/labstack/echo@v2, as it is not allowed by constraint ^4.0.0 from project github.com/rmasclef/awesomeProject.

Steps to reproduce

Gopkg.toml

[prune]
  go-tests = true
  unused-packages = true

[[constraint]]
  name = "github.com/labstack/echo"
  version = "^4.0"

main.go

package main

import (
    "net/http"

    "github.com/labstack/echo/v4"
    "github.com/labstack/echo/v4/middleware"
)

func main() {
    // Echo instance
    e := echo.New()

    // Middleware
    e.Use(middleware.Logger())
    e.Use(middleware.Recover())

    // Routes
    e.GET("/", hello)

    // Start server
    e.Logger.Fatal(e.Start(":1323"))
}

// Handler
func hello(c echo.Context) error {
    return c.String(http.StatusOK, "Hello, World!")
}

Version/commit

  • go version : 1.11.5 darwin/amd64
  • gomodules: disabled
wontfix

All 7 comments

Maybe this is the expected (v4 can not be used without gomodules)

If so, I suggest updating the README.md in order to be clearer 馃憤

The README simply copied those notes about the versions from the official documentation, we did not come up with them on our own: https://github.com/golang/go/wiki/Modules#non-module-code-consuming-modules

As you can see here: https://golang.org/doc/devel/release.html#go1.9.minor and here: https://go.googlesource.com/go/+/d4e21288e444d3ffd30d1a0737f15ea3fc3b8ad9 they clearly did backport some functionality to that version (and I assume the same for 1.10.3 though I did not check) in order to have it work with Go modules.

That being said, while those versions do work with latest Echo just fine, there is indeed a mistake in the README in the sense that you cannot import it as v4, but have to use the regular import (without v4) suffix, which WILL in fact bring you the latest version of the library.

$ go version
go version go1.9.7 linux/amd64

$ cat x.go 
package main

import "github.com/labstack/echo"
import m "github.com/labstack/echo/middleware"

func main() {
    println(echo.Version)
    _ = m.CSRFConfig{}
}

$ go run x.go 
4.0.0

As you can see, latest Echo of version, including middleware, worked just fine with Go 1.9.7 in spite of the fact that internally (the middleware package) uses echo/v4 imports. I will make the clarification about the import path for older Go versions, vs new ones though, to make it clearer.


Now whether you can lock the vN version of a Go module package from another dependency manager, that is entirely a question for the respective dependency manager, a question that was in fact asked already here: https://github.com/golang/dep/issues/1962

Hope this helps!

Thank you for that answer 馃憤

As you said, after the README update, the problem will be, indeed, in the dependency manager side.

So regarding dep:

  • adding a dependency constraint on v4 will "not work".
  • Adding no constraint (or a constraint on master branch) will "work".

I don't know if it is a good idea but, as a lot of go devs use dep, maybe it will be nice to add this behavior as a warning or something like this in the README ?

to me a simple change from this :

Any of these versions will allow you to import Echo as github.com/labstack/echo/v4 which is the recommended way of using Echo going forward.

to this:

Any of these versions will allow you to import Echo as github.com/labstack/echo/v4 using gomodule which is the recommended way of using Echo going forward.
For older versions or if you are not using gomodules yet, use the latest v3 tag

it might be nothing but, imho, it is way clearer like this 馃憤

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Honestly, this change screw many people, like me, suffix are not supported by other tools, don't get me wrong, go mod is the future, but not all packages/dependencies are migrated yet, so basically I would be pinned to a v3 tag until everybody migrates their packages to go mod. I don't see a real benefit on adding that

Thank you for that answer 馃憤

As you said, after the README update, the problem will be, indeed, in the dependency manager side.

So regarding dep:

  • adding a dependency constraint on v4 will "not work".
  • Adding no constraint (or a constraint on master branch) will "work".

I don't know if it is a good idea but, as a lot of go devs use dep, maybe it will be nice to add this behavior as a warning or something like this in the README ?

pin to master doesn't work, cause middleware package is using /v4 suffix

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leoycx picture leoycx  路  4Comments

arun0009 picture arun0009  路  3Comments

mmindenhall picture mmindenhall  路  4Comments

dre1080 picture dre1080  路  4Comments

asdine picture asdine  路  3Comments