让我讲述这个问题.我有一个名为«Image»的表格.它包含一个名为«file»的字段,它被检查为Image实现.这是validation.yml的一部分:
noxaeterna\MainBundle\Model\Image:
constraints:
- Propel\PropelBundle\Validator\Constraints\UniqueObject:
fields: hash
message: "????? ??????????? ??? ??????????."
properties:
name:
- NotBlank:
message: "??? ??????????? ?? ??????."
- Length:
max: 255
maxMessage: "????? ???????? ?? ?????? ????????? {{ limit }} ????????."
file:
- NotBlank:
message: "??????????? ?? ?????????"
- Image:
maxSize: 20M
mimeTypes: ["image/jpeg", "image/gif", "image/png", "image/x-png", "image/x-citrix-png", "image/x-citrix-jpeg", "image/pjpeg"]
minWidth: 1
minHeight: 1
minWidthMessage: "??????????? ?????? ???? ?? ????? {{ limit }} ???????? ? ??????."
minHeightMessage: "??????????? ?????? ???? ?? ????? {{ limit }} ???????? …Run Code Online (Sandbox Code Playgroud) 我有一个代码:
var test string
func main() {
http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
test = "index"
})
fmt.Println(test)
if error := http.ListenAndServe(":9001", nil); error != nil {
log.Fatal("Error!", error)
}
}
Run Code Online (Sandbox Code Playgroud)
如何在匿名函数中更改测试变量的值?我会很感激的!
我想知道将任何数据发送到模板(html /模板包)的真正方法是什么?我的代码如下:
var templates = template.Must(template.ParseFiles(
path.Join(this.currentDirectory, "views/base.html"),
path.Join(this.currentDirectory, "views/main/test.html"),
))
templates.Execute(response, map[string]string{
"Variable": "????!",
})
Run Code Online (Sandbox Code Playgroud)
这是模板:
{{define "content"}}
{{ .Variable }}
{{end}}
Run Code Online (Sandbox Code Playgroud)
我会很感激的!