Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

golang print echo.Context values

Tags:

go

go-echo

I'm brand new to Go and trying to inspect a method argument. I've got the following code

func (c *controller) OrderNew(ctx echo.Context) error {

When I try either:

    fmt.println(ctx)
    fmt.Printf("%v \n", ctx)

I get

&{0xc4200f21e0 0xc4202302d0 /order [] [] map[] 0x4092860 map[site_key:2] 0xc4200bb6c0}

I realize *controller is a pointer and the values returned contain addresses, but not sure how to really debug or inspect further. I also see functions called on cxt like

ctx.Get and ctx.Render

which I realize are functions in echo.Context

Any help/clarification is appreciated. Thanks!

like image 577
jj1111 Avatar asked Oct 23 '25 10:10

jj1111


1 Answers

use log package.

log.Printf("CONTEXT %+v", ctx)
like image 65
Victra Avatar answered Oct 26 '25 03:10

Victra