{"id":183508,"date":"2013-08-24T21:33:03","date_gmt":"2013-08-24T17:33:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=183508"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=183508","title":{"rendered":"<span class=\"post_title\">\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0433\u043e Web-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 Go<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041a\u043e\u0433\u0434\u0430 \u044f \u0437\u0430\u0434\u0443\u043c\u0430\u043b\u0441\u044f \u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 Web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Go, \u044f \u043f\u0440\u0435\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b \u043b\u0438\u0448\u044c \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0435 \u0434\u043b\u044f \u0441\u0435\u0431\u044f. \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u044f \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e Web \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u043a\u0440\u043e\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u0443\u044e GUI \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0447\u0435\u043c \u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435[<a href=\"http:\/\/mapitemeditor.sourceforge.net\/\">1<\/a>].<br \/>  <a name=\"habracut\"><\/a><\/p>\n<h5>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h5>\n<p>  \u041e\u0442\u043b\u0438\u0447\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0443\u0440\u043e\u043a\u0430 \u043e\u0442 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u043e, \u0447\u0442\u043e \u044f \u0431\u0443\u0434\u0443 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b Go. \u0414\u043b\u044f \u043c\u043e\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0434\u0430 \u0438 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u0445 (\u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 Revel[<a href=\"http:\/\/habrahabr.ru\/post\/162115\/\">2<\/a>]) \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u0431\u044b\u043b\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u044f. \u0422\u0430\u043a-\u0436\u0435 \u044f \u0437\u0430\u0442\u0440\u043e\u043d\u0443 \u0442\u0435\u043c\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u041e\u043f\u044f\u0442\u044c-\u0436\u0435, \u0447\u0435\u0442\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u043d\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043a\u0435\u043b\u0435\u0442, \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<p>  \u0412 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438, \u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043c\u0430 \u043a\u043e\u0434\u0430. \u0422\u0430\u043a-\u0436\u0435 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0449\u0438, \u0432\u0440\u043e\u0434\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (\u0443\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438[<a href=\"http:\/\/golang.org\/doc\/\">3<\/a>][<a href=\"http:\/\/golang.org\/pkg\/\">4<\/a>]). \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b, \u0434\u043b\u044f \u044f\u0441\u043d\u043e\u0441\u0442\u0438, \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0435 \u0441\u0442\u0440\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c, \u0438\u043b\u0438 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0432\u0435\u0440\u043d\u043e.<\/p>\n<h5>\u041d\u0430\u0447\u0430\u043b\u043e<\/h5>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u00abHello World\u00bb. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a (<b>handler<\/b>):  <\/p>\n<pre><code class=\"go\">func index(w http.ResponseWriter, r *http.Request) { \tw.Header().Set(&quot;Content-type&quot;, &quot;text\/plain&quot;) \tw.Write([]byte(&quot;Hello World!!!&quot;)) } <\/code><\/pre>\n<p>  \u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f <b>ResponseWriter<\/b> \u0438 <b>Request<\/b>. <b>ResponseWriter<\/b> \u2013 \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f HTTP \u043e\u0442\u0432\u0435\u0442\u0430, <b>Request<\/b> \u2013 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f HTTP \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0443. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0442\u0438\u043f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u00ab\u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u00bb, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u043d\u0430\u0448\u0443 \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0436\u0435 \u00ab\u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c\u00bb \u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043a \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0443:  <\/p>\n<pre><code class=\"go\">func main() { \thttp.HandleFunc(&quot;\/&quot;, index)  \thttp.ListenAndServe(&quot;:80&quot;, nil) } <\/code><\/pre>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <b>HandleFunc<\/b> \u043c\u044b \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043a \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0443, \u0430 c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <b>ListenAndServe<\/b> \u0443\u0436\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440. \u041f\u0430\u0442\u0442\u0435\u0440\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u044b\u043c: \u00ab\/\u00bb, \u00ab\/page0\u00bb, \u00ab\/page0\/page01\u00bb. \u041d\u043e \u0432\u0441\u0435 \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430, \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043d\u0435\u043c\u0443. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0443 \u043d\u0430\u0441 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0434\u0432\u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430: \u00ab\/\u00bb \u0438 \u00ab\/page0\u00bb. \u0415\u0441\u043b\u0438 \u0432 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u00ab\/page\u00bb, \u0442\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a \u00ab\/\u00bb, \u0430 \u0435\u0441\u043b\u0438 \u00ab\/page0\/page\u00bb, \u0442\u043e \u043a \u00ab\/page0\u00bb. \u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"go\">package main  import ( \t&quot;net\/http&quot; )  func index(w http.ResponseWriter, r *http.Request) { \tw.Header().Set(&quot;Content-type&quot;, &quot;text\/plain&quot;) \tw.Write([]byte(&quot;Hello World!!!&quot;)) }  func main() { \thttp.HandleFunc(&quot;\/&quot;, index)  \thttp.ListenAndServe(&quot;:80&quot;, nil) } <\/code><\/pre>\n<p>  \u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c (\u0438\u043b\u0438 \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c), \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 \u0433\u0434\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0441\u0435\u0440\u0432\u0435\u0440 (\u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u044d\u0442\u043e localhost \u2013 127.0.0.1) \u0438 \u0432\u0438\u0434\u0438\u043c \u043d\u0430\u0448\u0443 \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<h5>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u044b<\/h5>\n<p>  \u00ab\u0412\u0448\u0438\u0442\u044b\u0439\u00bb html-\u043a\u043e\u0434 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0440\u0430\u0439\u043d\u0435 \u0443\u0440\u043e\u0434\u043b\u0438\u0432\u043e \u0438 \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043d\u0435\u0443\u0434\u043e\u0431\u0435\u043d \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445):  <\/p>\n<pre><code class=\"go\">fmt.Fprintf(w, &quot;&lt;h1&gt;Editing %s&lt;\/h1&gt;&quot;+ \t&quot;&lt;form action=\\&quot;\/save\/%s\\&quot; method=\\&quot;POST\\&quot;&gt;&quot;+ \t&quot;&lt;textarea name=\\&quot;body\\&quot;&gt;%s&lt;\/textarea&gt;&lt;br&gt;&quot;+ \t&quot;&lt;input type=\\&quot;submit\\&quot; value=\\&quot;Save\\&quot;&gt;&quot;+ \t&quot;&lt;\/form&gt;&quot;, \tp.Title, p.Title, p.Body) <\/code><\/pre>\n<p>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043f\u0430\u043a\u0435\u0442\u043e\u043c <b>template<\/b>, \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u00ab\u043a\u043e\u0441\u0442\u044f\u043a\u00bb \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b (\u044f \u0431\u0443\u0434\u0443 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u0443\u044f\u0441\u044c \u043d\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 HTML5):  <\/p>\n<pre><code class=\"html\">&lt;!DOCTYPE html&gt;  &lt;html&gt; \t&lt;head&gt; \t\t&lt;meta charset=&quot;utf-8&quot;&gt; \t\t&lt;title&gt;{{.Title}}&lt;\/title&gt; \t&lt;\/head&gt; \t&lt;body&gt; \t\t&lt;p&gt;{{.Msg}}&lt;\/p&gt; \t&lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  <b>Title<\/b> \u0438 <b>Msg<\/b> \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u044f\u0442\u0441\u044f \u0432 \u0442\u0435\u043a\u0441\u0442, \u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043f\u043e\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438:  <\/p>\n<pre><code class=\"go\">type page struct { \tTitle string\t\/\/\u0438\u043c\u0435\u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0432\u044b\u0448\u0435! \tMsg string\t\t\/\/\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u043c\u0438! } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a:  <\/p>\n<pre><code class=\"go\">func index(w http.ResponseWriter, r *http.Request) { \tw.Header().Set(&quot;Content-type&quot;, &quot;text\/html&quot;)  \tt, _ := template.ParseFiles(\u201cindex.html\u201d) \tt.Execute(w, &page{Title: &quot;Just page&quot;, Msg: &quot;Hello World&quot;}) } <\/code><\/pre>\n<p>  <b>ParseFiles<\/b> \u2013 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b (\u0438\u043b\u0438 \u0444\u0430\u0439\u043b\u044b), <b>Execute<\/b> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d, \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0434\u0430\u043d\u043d\u044b\u0435, \u0438 \u043f\u0438\u0448\u0435\u0442 \u0438\u0445 \u0432 <b>w<\/b>.<\/p>\n<h5>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439<\/h5>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043a\u043d\u043e\u043f\u043a\u043e\u0439, \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0444\u0430\u0439\u043b\u0430 \u0438 \u0442.\u043f. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u0438\u043c\u0435\u0442 \u0444\u0430\u0439\u043b \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c, \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e \u0432 JPEG \u0441 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e\u043c 0 (\u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u044f\u0441\u043d\u043e \u0432\u0438\u0434\u043d\u043e \u0447\u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442), \u0438 \u0432\u0435\u0440\u043d\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u043e.<\/p>\n<p>  \u0418\u0437\u043c\u0435\u043d\u0438\u043c \u043d\u0430\u0448 html-\u0448\u0430\u0431\u043b\u043e\u043d, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u043d\u0435\u0433\u043e \u0444\u043e\u0440\u043c\u0443 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c POST:  <\/p>\n<pre><code class=\"html\">&lt;form target=&quot;_blank&quot; action=&quot;\/exec\/&quot; enctype=&quot;multipart\/form-data&quot; method=&quot;post&quot;&gt; \t&lt;input type=&quot;file&quot; name=&quot;imgfile&quot; \/&gt; \t&lt;input type=&quot;submit&quot; name=&quot;button&quot; value=&quot;Execute&quot; \/&gt; &lt;\/form&gt; <\/code><\/pre>\n<p>  \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a:  <\/p>\n<pre><code class=\"go\">func index(w http.ResponseWriter, r *http.Request) { \tw.Header().Set(&quot;Content-type&quot;, &quot;text\/html&quot;)  \ttitle := r.URL.Path[len(&quot;\/&quot;):]  \tif title != &quot;exec\/&quot; { \t\tt, _ := template.ParseFiles(&quot;index.html&quot;) \t\tt.Execute(w, &page{Title: &quot;Convert Image&quot;}) \t} else { \t\timgfile, fhead, _ := r.FormFile(&quot;imgfile&quot;)  \t\timg, ext, _ := image.Decode(imgfile)  \t\tw.Header().Set(&quot;Content-type&quot;, &quot;image\/jpeg&quot;) \t\tw.Header().Set(&quot;Content-Disposition&quot;, &quot;filename=\\&quot;&quot; + fhead.Filename + &quot;.&quot; + ext + &quot;\\&quot;&quot;) \t\tjpeg.Encode(w, img, &jpeg.Options{0}) \t} } <\/code><\/pre>\n<p>  \u0412 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <b>title<\/b> \u0431\u0443\u0434\u0435\u0442 \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0435\u0441\u043b\u0438 \u0430\u0434\u0440\u0435\u0441 \u00abhttp:\/\/localhost\/qwe\/\u00bb, \u0442\u043e \u0432 <b>title<\/b> \u0431\u0443\u0434\u0435\u0442 \u00abqwe\/\u00bb. \u0414\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u043d\u0430 \u00abexec\/\u00bb, \u0442\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043e\u0431\u044b\u0447\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u0435\u0441\u043b\u0438 \u0436\u0435 \u043c\u044b \u043d\u0430 \u00abexec\/\u00bb, \u0442\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0444\u0430\u0439\u043b. <b>FormFile<\/b> \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c (\u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u0438\u0445 \u0444\u043e\u0440\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e, \u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445) \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0444\u0430\u0439\u043b\u0435. \u041c\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0442\u0438\u043f \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 (\u043a\u0430\u043a \u00abimage\/jpeg\u00bb), \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 (\u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u043e\u0448\u043b\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0443 \u0441 \u044d\u0442\u0438\u043c \u0438\u043c\u0435\u043d\u0435\u043c) \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>  \u0418 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442, \u0435\u0441\u043b\u0438 \u0432\u044b \u0432 \u0441\u0432\u043e\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0444\u0430\u0439\u043b \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c), \u0442\u043e \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <b>FileServer<\/b> \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430 <b>http<\/b>. \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u0432\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435:  <\/p>\n<pre><code class=\"go\">func logo(w http.ResponseWriter, r *http.Request) { \tfile, _ := ioutil.ReadFile(&quot;img\/logo.png&quot;) \tw.Write(file) }  &lt;...&gt; \thttp.HandleFunc(&quot;\/img\/logo.png&quot;, logo) &lt;...&gt; <\/code><\/pre>\n<p>  \u0410 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0432\u0441\u0435 \u043f\u0440\u043e\u0449\u0435, \u0442.\u043a. \u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b:  <\/p>\n<pre><code class=\"go\">&lt;...&gt; \thttp.Handle(&quot;\/img\/&quot;, http.FileServer(http.Dir(&quot;img&quot;))) &lt;...&gt; <\/code><\/pre>\n<h5>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h5>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043d\u0430 Go \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0435 Web-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 Go, \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0441\u0430\u043c\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430, \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 http-\u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432, \u0430 \u0442\u0430\u043a-\u0436\u0435 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c Go, \u043e\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. Go, \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442: FreeBSD (x86, amd64, arm), NetBSD(x86, amd64), GNU\/Linux (x86, amd64, arm), MacOS X (x86, amd64), Windows (x86, amd64).<\/p>\n<hr\/>\n<p>  [1] <a href=\"http:\/\/mapitemeditor.sourceforge.net\/\">mapitemeditor.sourceforge.net\/<\/a><br \/>  [2] <a href=\"http:\/\/habrahabr.ru\/post\/162115\/\">habrahabr.ru\/post\/162115\/<\/a><br \/>  [3] <a href=\"http:\/\/golang.org\/doc\/\">golang.org\/doc\/<\/a><br \/>  [4] <a href=\"http:\/\/golang.org\/pkg\/\">golang.org\/pkg\/<\/a>    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/183508\/\"> http:\/\/habrahabr.ru\/post\/183508\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041a\u043e\u0433\u0434\u0430 \u044f \u0437\u0430\u0434\u0443\u043c\u0430\u043b\u0441\u044f \u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 Web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Go, \u044f \u043f\u0440\u0435\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b \u043b\u0438\u0448\u044c \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0447\u0442\u043e \u043d\u043e\u0432\u043e\u0435 \u0434\u043b\u044f \u0441\u0435\u0431\u044f. \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u044f \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e Web \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u043a\u0440\u043e\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u0443\u044e GUI \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0447\u0435\u043c \u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435[<a href=\"http:\/\/mapitemeditor.sourceforge.net\/\">1<\/a>].  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-183508","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/183508","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=183508"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/183508\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=183508"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=183508"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=183508"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}