Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with gin template rendering #864

Open
hello-sucess opened this issue Aug 10, 2024 · 1 comment
Open

Problems with gin template rendering #864

hello-sucess opened this issue Aug 10, 2024 · 1 comment
Labels
bug Something isn't working reflection

Comments

@hello-sucess
Copy link

What version of Garble and Go are you using?

mvdan.cc/garble v0.12.1

go1.22.6

What environment are you running Garble on?

go env Output
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/admin/.cache/go-build'
GOENV='/home/admin/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/admin/Code/pkg/mod'
GONOPROXY='*'
GONOSUMDB='*'
GOOS='linux'
GOPATH='/home/admin/Code'
GOPRIVATE='*'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/admin/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/admin/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.6'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/admin/Code/src/test/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1548521202=/tmp/go-build -gno-record-gcc-switches'

What did you do?

    {{$prive := .priveall}} {{range $v := $prive}} {{if $v.IsOpen }}
  • {{$v.Title}}
  • {{end}} {{end}}

What did you expect to see?

Use bool and other interface{} types in html templates.

What did you see instead?

Error with bool type in gin template rendering.

Error #1: template: test.html:14:11: executing "test.html" at <$v.IsOpen>: can't evaluate field IsOpen in type CC3Eu0GdG_jK.OSgLH1cBblg

@hello-sucess
Copy link
Author

The IsOpen here is from the gorm database model, by looking up the database, returning a []model.User list, and then one of the fields is IsOpen, a boolean type. If you pass the boolean type directly to the gin template, it will be recognized.

@lu4p lu4p added reflection bug Something isn't working labels Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working reflection
Development

No branches or pull requests

2 participants