Skip to content

does echo.Reverse() handle pointer parameters? #2430

Answered by aldas
msonawane asked this question in Q&A
Discussion options

You must be logged in to vote

You are doing it wrong. That second parameter to Reverse should not be pointer. Remove & and you are fine.

This is example from tests

echo/echo_test.go

Lines 1529 to 1539 in de1c798

assert.Equal(t, "/static", e.Reverse("/static"))
assert.Equal(t, "/static", e.Reverse("/static", "missing param"))
assert.Equal(t, "/static/*", e.Reverse("/static/*"))
assert.Equal(t, "/static/foo.txt", e.Reverse("/static/*", "foo.txt"))
assert.Equal(t, "/params/:foo", e.Reverse("/params/:foo"))
assert.Equal(t, "/params/one", e.Reverse("/params/:foo", "one"))
assert.Equal(t, "/params/:foo/bar/:qux", e.Reverse("/params/:foo/bar/:qux"))
assert.Equal(t, "/params…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aldas
Comment options

Answer selected by aldas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants