GO? ??? ??? ???/??? ? HTML/??? ???? ?? ??? ?? ??? ?? ??? ?????. ??? HTML/Template?? XSS ??? ?????? ?? ?? ??? ???? HTML? ?? ? ? ?? ???????. 1. {{{}} ??? ???? {{.fieldname}}? ?? ??, ??? ?? ? ??? ???? ?? ??? ????? ??? ??? ?????. 2. ???? ??, ???? ? ?? ?? GO ??? ??? ???? ??? ??? ?? ?? ??? ?????. 3. ?? ? ???? ??? ???? ???? ????? ?? ? ? ????. 4. html/???? ???? HTML ?? ??? ?????. ?? HTML? ??? ???? ?? Template.html ??? ????? ??? ??? ?? ? ???????. 5. ??? ???? ???? ??? ??? ??????? ???? ???? ??????. 6. ?? ???? ??? ????? : ?? ?? ???, ???? ??? ?? ?? ??? ??, ?? ? ?? ??? ???? ??? ? ? GO ??? ???? ???? ???? ?? ????? ?????? ??? ??????.
text/template
? html/template
?????? Go? ?? ??? ??? ?? ???, ?? ?? ?? HTML ? ??? ? ?? ???? ???? ???? ???? ?????. ??? ???? ?? ? Go? ?? ? ???? ?? ??? ????. ??? Go? ??? ???? ??? ???? ? ????? ???? ??????.

1. text/template
vs html/template
??
Go? ? ?? ?? ??? ???? ?????.
-
text/template
: ?? ??? ???? ?? ?? ?? ??? (? : ?? ??, ???, CLI ??). -
html/template
:text/template
?? ?????? XSS ??? ???? ?? ?? ???? ?? ???????? HTML ??? ??? ???????.
? HTML? ?? ? ? html/template
??????. ????? ? ?????.

?? (??) "???/???"// ?? ???? ?? "html/???"// html? ?? ))
2. ?? ??? ??
???? ?? ???? {{ }}
???? ??? ?????. ???? ??? ??? ????.
-
{{.}}
- ?? ??? ( "dot")? ?????. -
{{.FieldName}}
- ????? ??? ?????? -
{{if .Condition}}...{{end}}
- ??? ?? -
{{range .Items}}...{{end}}
- ????, ? ?? ?? ?? ?? -
{{template "name"}}
- ??? ??? ???? ??????
? : ??? ??
tmpl : =`hello, {{.name}}!` ??? : = struct {name String} {?? : "Alice"} t : = template.new ( "??") t, _ = t.parse (tmpl) T.Execute (OS.Stdout, ???) // ?? : ?????, ???!
3. ???? ????, ???? ???
GO ???? GO ??? ??? ???? ?????.

??????? ??? ?? :
?? ?? struct { ?? ??? ?? [] ??? } ??? : = ?? { ?? : "?", ?? : [] String { "Golang", "Hiking", "Reading"}, } tmpl : =` ?? : {{.name}} ?? : {{range .hobbies}}- {{.}} {{?}} ` template.must (template.new ( "person"). Parse (tmpl)). Execute (os.stdout, data)
??:
?? : ? ?? : -Golang - ??? - ??
?? :
range
?? DOT (.
)? ??? ?? ???? ?????.
4. ?? ?? : else
if
range
GO ???? ?? ??? ?????.
-
{{if .Value}}...{{else}}...{{end}}
?? - ? ????, nil ???, ?? ?? False? ?????
{{if .loggedin}} ?? ?? ?? ?????, {{.username}}! {{? ??}} ???????. {{?}}
?? ?? ( eq
, ne
, lt
, gt
?)? ???? ?? ??? ?? ????.
{{if eq .Status "active"}}} <p> ?? : Active </p> {{?}}
??? ?? ??? ???? ?? ??? ?? GO ??? ????.
5. define
? template
?? ??? ??? ??? ??
??? ??? ???? ???? ???? ? ????.
const tmpl =` {{?? "greet"}} hello, {{.}}! {{end}} {{??? "greet" "Alice"}} {{??? "greet" "Bob"}} ` t, _ : = template.new ( "main"). ?? ?? (tmpl) T.Execute (OS.Stdout, NIL)
? ?? ??, ?? ? ?? ??? ??? UI ?? ??? ?????.
6. html/template
???? ?????
HTML? ?? ? ?? ?? XSS? ???? ?? html/template
??????.
"html/???"?? ?? ??? : = struct { ?? ??? } {?? : "<cript> alert ( 'hack') </script>"} tmpl : =`<p> {{. content}} </p>` t, _ : = template.new ( "Safe"). Parse (TMPL) T.Execute (OS.Stdout, ???)
? ?? :
<p> & lt; script & gt; Alert (' hack ') & lt;/script & gt; </p>
??? ???? ?????. RAW HTML? ??? ??? ?? template.HTML
??? ??????.
?? ??? ??? { ??? ??? .html } data : = page {content : template.html ( "<strong> Safe html </strong>")}
?? {{.Content}}
???? ?? ??????.
??? ??? ??? ?????? ??? ?????.
7. ????? ??? ?? ( define
? block
??)
GO?? ?? ??? ??? define
? template
???? ???? ???? ????? ? ? ????.
?? ???? ( layout.html
) :
<! doctype html> <html> <head> <title> {{block "title".}} ?? ?? {{end}} </title> </head> <body> <Header> <H1> ? ??? </h1> </header> <main> {{block "content".}} ?? ??? {{end}} </main> </body> </html>
??? ??? :
{{?? "title"}} home {{end}} {{ "content ??"}} <p> ????? ?? ?? ?????! </p> {{?}}
GO ?? :
tpl : = template.must (template.new ( "base"). parsefiles ( "layout.html", "home.html")). tpl.executetemplate (Os.stdout, "Base", NIL)
? ??? ???? ?? ?, ??? ??? ????? ?? ? ? ????.
8. ?? ??
- HTML ???? ??
html/template
??????. - preation ??? ?? ??? (?? ??? ?? ?? ???? ????).
-
template.Must()
??? ?? ???? ??? ?? ??????. - themplate ????? ?? ???? ??????.
- the ??? ???? ????
ParseFiles
??ParseGlob
?????.
// ???? ?? ????????? tpl : = template.must (template.parseglob ( "templates/*. html")))
GO? ??? ??? ?? ??? ?? ??? ???? ? ??? ???, ?? ?? ? ?? ??? ??? ??? ?? ????, ?? ? ??? ???? ? ??????.
?????, ?? ?, ?? ? ?? ??? ??? GO ???? ??? ??????.
? ??? Go? ??? ??? ?? ???? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

GO? ??? ??? ???/??? ? HTML/??? ???? ?? ??? ?? ??? ?? ??? ?????. ??? HTML/Template?? XSS ??? ?????? ?? ?? ??? ???? HTML? ?? ? ? ?? ???????. 1. {{{}} ??? ???? {{.fieldname}}? ?? ??, ??? ?? ? ??? ???? ?? ??? ????? ??? ??? ?????. 2. ???? ??, ???? ? ?? ?? GO ??? ??? ???? ??? ?? ?? ?? ??? ?????. 3. ?? ? ???? ??? ???? ???? ????? ?? ? ? ????. 4.ht

????? ?? ? ? ???? ???? ?? ??? ?? ???? ???? ?? ???? ??? ???? ?? ???? ???? ?? ??? ????? ??? ?? ?????. ??? ??? ?? ??? ?? ????? ??? ????. 1. ?? ??? ???? ??? ? ????? ?? ???? ?? ?? ??? ?? ???? ?? ???? ???? ???????. 2. ??? ??? ???? ???? ?? ????? ?? ??? ? ????. 3. Append? ??? ? ? ??? ??? ? ??? ?? ???? ???? ???? ? ????? ??? ?????????. ??? ?? ????? ???? ??? ????? ? ??? ????????.

GO ? KAFKA ??? ??? ??? ??? ???? ?????? ???? ??????. ??? ????? ?????? ??? ?? ???????. 1. ??? GO ??? API? ??? ???? ??? ?? ?? Kafka-Go? ?? ??? ?????. ?? ??? ?????. 2. ?? ?? ?? ?? ??? ??? ?? Sarama? ??????. 3. ???? ??? ?? ??? ??? ??, ?? ??? ??? ??? ???? ????? ?? ?? ?? ? ??? ???????. 4. ???? ??? ??? ???? ?? ?? ?? ?? ??? ???? ???? ???? ???? ?? ??? ????? ???????. 5. ???? ?? JSON, AVRO ?? Protobuf? ???? SchemareGist? ???? ?? ????.

govetcatchescommonlogicalErrorsandspuctructsingocodesuchas1) missuseofprintf-stylefunctionswithorrectarguments, 2) unkeyedstructliterals thatmayLeadiffieldAssignments, 3) senfingToclosedChannelswhichcaUsespanics, 4) inffectVeasment

asereFlect.ValueOfandReflect.typeOftOgetRuntimeValuesandTypes; 2.InspectTyPedEtailSwitHreflect.typemetHodSlikEname () andkind (); 3. modifyValuesViAreflect.value.elem () andcanset () nejectpassingApointer; 4.CallMethodsDynamalicalLySUNINGENTMETHODBYNAME () ? CALL (); 5.R

Go Language?? HTTP ????? ??? ?? ????, ?? ??? ??? ????. ????? ?? ?? ??? ?? ??? ???? ? ???? http.handler? ???? ???? ?????. 1. ???? ?? ??? func (middleware (nexthttp.handler) http.handler)? ????. 2. ??? ?? ????? ?? ???, ??, ????? ?? ? ?? ?? ??? ????, ?? ???? ? ???? ?????. 3. ?? ????? ?? ??? ???? ??? ??? ???? ???? ??? 401 ?? 403 ??? ?????. 4. ?? ????? ???? ??? ? ????

GO? ??? ???? ????? ???? ???? ???? ??? ? ?? ??? ?? ? ? ???? ?????. 1. ???? ???? ???? ?? ?? ?? ?? ?? ? ????. 2. ?? ?? ??? ??? ???? ? ?? ? ?????. 3. ??? ??? ????? ?? ??? ??? ?? ? ? ????. 4. ???? ??? ?? ? ??? ??? ??? ?? ? ? ????. 5. Default? ????? ?? ???? ?? ??? ???? ??? ?????.

USECONTEXT.WITHTIMETOCREATEACALCELLABLECONTEXTWITHADEADENEANDALWAYSCALLCANCEL () TORELEASERESOURCES.2.FORHTTPREQUESTS, SENTI MeoutSusinghttp.client.TimeOutOrUseContextViahttp.newrequestwithContextForper-RequestControl.3. ingoroutineswithChannels, Usese
