Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Problems with gin template rendering #912

Open
Labels
bugSomething isn't working
@5455230

Description

@5455230

What version of Garble and Go are you using?

garble version:mvdan.cc/garble v0.13.0Build settings:      -buildmode exe       -compiler gc     CGO_ENABLED 1          GOARCH amd64            GOOS windows         GOAMD64 v1go version:go version go1.22.5 windows/amd64

What did you do?
[]Item list,iii cannot be printed.

        {{range $value := .iii}}            value: {{$value.Size}}        {{end}}

garble build -mod=vendor -o bin/go_go.exe main.go

/main.go

package mainimport ("net/http""github.com/gin-gonic/gin")type Item struct {Page intSize int}func main() {r := gin.Default()r.LoadHTMLGlob("templates/*")r.GET("/index", func(c *gin.Context) {a := gin.H{"title": "titleAA","ce":    "123456","iii": []Item{{Page: 1, Size: 11},{Page: 2, Size: 12},{Page: 3, Size: 13},},}c.HTML(http.StatusOK, "index.html", a)})r.Run()}

/templates/index.html

<!DOCTYPE html><html lang="en"><head>    <title>{{.title}}</title></head>    <body>        iii:        {{range $value := .iii}}            value: {{$value.Size}}        {{end}}    </body></html>

GET:http://127.0.0.1:8080/index
Error #01: template: index.html:9:27: executing "index.html" at <$value.Size>: can't evaluate field Size in type main.B0aMZmq6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp