{"id":267366,"date":"2015-11-03T11:04:02","date_gmt":"2015-11-03T08:04:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=267366"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=267366","title":{"rendered":"\u0421\u0432\u043e\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043b\u043e\u0433\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 GO \u0432 5 \u0443\u0440\u043e\u0432\u043d\u0435\u0439"},"content":{"rendered":"<p>       \u042d\u0442\u043e \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0425\u0430\u0431\u0440\u0435, \u043f\u0438\u0448\u0443 \u0435\u0451 \u043f\u043e \u0445\u043e\u0434\u0443 \u0441\u0432\u043e\u0435\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u0417\u0430 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 \u0431\u0443\u0434\u0443 \u043e\u0447\u0435\u043d\u044c \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0435\u043d.<\/p>\n<p>  <a href=\"http:\/\/habrahabr.ru\/post\/98638\/\">\u0417\u0434\u0435\u0441\u044c<\/a> \u0430\u0432\u0442\u043e\u0440 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0438\u043c\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043b\u043e\u0433\u0438. \u0412 \u0441\u0432\u043e\u0435\u043c \u0446\u0438\u043a\u043b\u0435 \u0441\u0442\u0430\u0442\u0435\u0439 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0432\u0430\u043c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0438\u043c\u0438 \u0440\u0443\u043a\u0430\u043c\u0438 \u043d\u0430 GO.<\/p>\n<p>  \u0418\u0442\u0430\u043a \u043d\u0430\u0447\u043d\u0451\u043c. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 tcp \u0441\u0435\u0440\u0432\u0435\u0440:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">tcp \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 golang<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"go\">package main  import (  \t&quot;log&quot; \t&quot;net&quot; )  func main() {  \t\/\/\u0432\u0435\u0448\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 2000 \u043f\u043e\u0440\u0442 \tl, err := net.Listen(&quot;tcp&quot;, &quot;:2000&quot;) \tif err != nil { \t\tlog.Fatal(err) \t} \tdefer l.Close() \tfor { \t\t\/\/\u0412 \u0432\u0435\u0447\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 &quot;\u0441\u043b\u0443\u0448\u0430\u0435\u043c&quot; 2000 \u043f\u043e\u0440\u0442. \u0416\u0434\u0451\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \t\tconn, err := l.Accept() \t\tif err != nil { \t\t\tlog.Fatal(err) \t\t} \t\t\/\/\u041a \u043d\u0430\u043c \u043a\u0442\u043e \u0442\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0441\u044f. \u041e\u0442\u043a\u0440\u043e\u0435\u043c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0441\u0432\u043e\u044e \u0433\u043e\u0440\u0443\u0442\u0438\u043d\u0443 \t\tgo func(c net.Conn) {  \t\t\t\/\/\u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0431\u0443\u0444\u0435\u0440 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0432\u043d\u0435. \t\t\tbuf := make([]byte, 1024)  \t\t\t\/\/\u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0432\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c n \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \t\t\t\/\/ \u0430 \u043d\u0435 \u043e\u0434\u043d\u043e \t\t\tfor { \t\t\t\t\/\/\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u0438\u0448\u0435\u043c \u0432 \u0431\u0443\u0444\u0435\u0440 \t\t\t\tc.Read(buf)  \t\t\t\tlog.Print(string(buf)) \t\t\t} \t\t}(conn) \t} } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0432 \u043d\u043e\u0432\u043e\u043c \u043e\u043a\u043e\u0448\u043a\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430 \u0434\u0435\u043b\u0430\u0435\u043c \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/pp.vk.me\/c629304\/v629304193\/1af0e\/WEg-JKHrFpQ.jpg\" alt=\"image\"\/>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u043c\u0438\u043d\u0438 api.<\/p>\n<p>  \/\/\u0442\u0438\u043f\u044b \u043b\u043e\u0433 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439<br \/>  Debug|][|\u0447\u0442\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043b\u043e\u0433 \u0431\u0443\u0444\u0435\u0440-&gt;150 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<br \/>  Info|][|\u0447\u0442\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043b\u043e\u0433 \u0431\u0443\u0444\u0435\u0440-&gt;100 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<br \/>  Warn|][|\u0447\u0442\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043b\u043e\u0433 \u0431\u0443\u0444\u0435\u0440-&gt;50 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<br \/>  Error|][|\u0447\u0442\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043b\u043e\u0433 \u0431\u0443\u0444\u0435\u0440-&gt;25 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<br \/>  Fatal|][|\u0447\u0442\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043b\u043e\u0433 \u0431\u0443\u0444\u0435\u0440-&gt;0 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/p>\n<p>  \/\/\u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0431\u0443\u0444\u0435\u0440\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u0431\u0434<br \/>  UnloadTheCacheDB|][|null<\/p>\n<p>  \/\/\u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0431\u0443\u0444\u0435\u0440 \u043d\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0431\u0434<br \/>  ClearCache|][|null<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0434:<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"go\">package main  import ( \t&quot;log&quot; \t&quot;net&quot; \t&quot;strings&quot; )  func main() { \tl, err := net.Listen(&quot;tcp&quot;, &quot;:2000&quot;) \tif err != nil { \t\tlog.Fatal(err) \t} \tdefer l.Close() \tfor {  \t\tconn, err := l.Accept() \t\tif err != nil { \t\t\tlog.Fatal(err) \t\t} \t\tgo func(c net.Conn) { \t\t\tbuf := make([]byte, 1024)  \t\t\tfor { \t\t\t\tc.Read(buf) \t\t\t\tresult := strings.Split(string(buf), &quot;|][|&quot;) \t\t\t\tswitch result[0] {  \t\t\t\tcase &quot;Debug&quot;: \t\t\t\t\tlog.Print(&quot;Debug log \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435=&quot; + result[1]) \t\t\t\tcase &quot;Info&quot;: \t\t\t\t\tlog.Print(&quot;Info log \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435=&quot; + result[1]) \t\t\t\tcase &quot;Warn&quot;: \t\t\t\t\tlog.Print(&quot;Warn log \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435=&quot; + result[1]) \t\t\t\tcase &quot;Error&quot;: \t\t\t\t\tlog.Print(&quot;Error log \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435=&quot; + result[1]) \t\t\t\tcase &quot;Fatal&quot;: \t\t\t\t\tlog.Print(&quot;Fatal log \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435=&quot; + result[1])  \t\t\t\tcase &quot;UnloadTheCacheDB&quot;:  \t\t\t\tcase &quot;ClearCache&quot;:  \t\t\t\tdefault: \t\t\t\t\tlog.Print(&quot;case Default\\n&quot;) \t\t\t\t\tc.Close() \t\t\t\t\treturn \t\t\t\t} \t\t\t} \t\t\tc.Close() \t\t}(conn) \t} } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u043e\u043c\u0430\u043d\u0434\u0430 == \u043b\u043e\u0433 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0435\u043c.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/pp.vk.me\/c629304\/v629304193\/1af22\/YUnPZmGtTwg.jpg\" alt=\"image\"\/>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u0432\u0430\u0441 \u0434\u0432\u0430 \u043f\u0443\u0442\u0438. \u041f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u0441\u044e\u0434\u0430 \u043c\u0435\u043c\u043a\u0435\u0448 \u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0431\u0434 \u043f\u0430\u0447\u043a\u0430\u043c\u0438 \u0438\u0437 \u043d\u0435\u0433\u043e, \u0438\u043b\u0438 \u0441\u0438\u0434\u0435\u0442\u044c \u0438 \u0436\u0434\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442 \u043c\u0435\u0436\u0434\u0443 go \u0440\u0443\u0442\u0438\u043d\u0430\u043c\u0438. <\/p>\n<p>  \u0412\u043e\u0442 \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u0441\u0451 \u043e\u0442\u043b\u0438\u0447\u043d\u043e, \u043f\u0440\u0430\u0432\u0434\u0430, \u0435\u0441\u043b\u0438 \u0432 1 \u043f\u043e\u0442\u043e\u043a. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0443\u0441\u044c \u0441 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0431\u043d\u043e\u0432\u043b\u044e \u0441\u0442\u0430\u0442\u044c\u044e.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"go\">package main  import ( \t&quot;database\/sql&quot; \t&quot;fmt&quot; \t_ &quot;github.com\/go-sql-driver\/mysql&quot; \/\/\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043b\u044e\u0431\u0443\u044e sql \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \t&quot;log&quot; \t&quot;net&quot; \t&quot;net\/smtp&quot; \t&quot;strings&quot;  \t&quot;time&quot; )  var DB *sql.DB  var i_debug int = 0 var cacheDebug string  var i_info int = 0 var cacheInfo string  var i_warn int =0 var cacheWarn string  var i_error int = 0 var cacheError string  func init() { \tdb, err := sql.Open(&quot;mysql&quot;, &quot;db_user:db_pass@\/logs_service&quot;) \tif err != nil { \t\tlog.Fatal(err) \t} \tDB = db } func main() {  \tl, err := net.Listen(&quot;tcp&quot;, &quot;:2000&quot;) \tif err != nil { \t\tlog.Fatal(err) \t} \tdefer l.Close() \tfor { \t\tconn, err := l.Accept() \t\tif err != nil { \t\t\tlog.Fatal(err) \t\t}  \t\tgo func(c net.Conn) {  \t\t\tbuf := make([]byte, 1024)  \t\t\tfor {  \t\t\t\tc.Read(buf)  \t\t\t\tresult := strings.Split(string(buf), &quot;|][|&quot;)  \t\t\t\tswitch result[0] {  \t\t\t\tcase &quot;Debug&quot;: \t\t\t\t\tif i_debug &lt;= 300 {  \t\t\t\t\t\tcacheDebug = cacheDebug + &quot;('&quot; + time.Now().String() + &quot;','&quot; + result[1] + &quot;')&quot;  \t\t\t\t\t\tgo DebugDB(cacheDebug)  \t\t\t\t\t\ti_debug = 0  \t\t\t\t\t\tcacheDebug = &quot; &quot; \t\t\t\t\t} else {  \t\t\t\t\t\tcacheDebug = cacheDebug + &quot;('&quot; + time.Now().String() + &quot;','&quot; + result[1] + &quot;'),&quot; \t\t\t\t\t}  \t\t\t\t\ti_debug++  \t\t\t\tcase &quot;Info&quot;: \t\t\t\t\tif i_info &lt;= 150 { \t\t\t\t\t\tcacheInfo = cacheInfo + &quot;('&quot; + time.Now().String() + &quot;','&quot; + result[1] + &quot;')&quot; \t\t\t\t\t\tgo InfoDB(cacheInfo) \t\t\t\t\t\ti_info = 0 \t\t\t\t\t\tcacheInfo = &quot; &quot; \t\t\t\t\t} else { \t\t\t\t\t\tcacheInfo = cacheInfo + &quot;('&quot; + time.Now().String() + &quot;','&quot; + result[1] + &quot;'),&quot; \t\t\t\t\t} \t\t\t\t\ti_info++  \t\t\t\tcase &quot;Warn&quot;: \t\t\t\t\tif i_warn &lt;= 50 { \t\t\t\t\t\tcacheWarn = cacheWarn + &quot;('&quot; + time.Now().String() + &quot;','&quot; + result[1] + &quot;')&quot; \t\t\t\t\t\tgo WarnDB(cacheWarn)  \t\t\t\t\t\ti_warn = 0 \t\t\t\t\t\tcacheWarn = &quot; &quot; \t\t\t\t\t} else { \t\t\t\t\t\tcacheWarn = cacheWarn + &quot;('&quot; + time.Now().String() + &quot;','&quot; + result[1] + &quot;'),&quot; \t\t\t\t\t} \t\t\t\t\ti_warn++  \t\t\t\tcase &quot;Error&quot;: \t\t\t\t\tif i_error == 25 { \t\t\t\t\t\tcacheError = cacheError + &quot;('&quot; + time.Now().String() + &quot;','&quot; + result[1] + &quot;')&quot; \t\t\t\t\t\tgo ErrorDB(cacheError)  \t\t\t\t\t\ti_error = 0 \t\t\t\t\t\tcacheError = &quot; &quot; \t\t\t\t\t\tcacheError = cacheError + &quot;('&quot; + time.Now().String() + &quot;','&quot; + result[1] + &quot;'),&quot; \t\t\t\t\t} \t\t\t\t\ti_error++  \t\t\t\tcase &quot;Fatal&quot;: \t\t\t\t\tgo FatalDB(result[1])  \t\t\t\tcase &quot;UnloadTheCacheDB&quot;:  \t\t\t\t\tgo DebugDB(cacheDebug) \t\t\t\t\tgo InfoDB(cacheInfo) \t\t\t\t\tgo WarnDB(cacheWarn) \t\t\t\t\tgo ErrorDB(cacheError)  \t\t\t\t\tcacheDebug = &quot; &quot; \t\t\t\t\tcacheInfo = &quot; &quot; \t\t\t\t\tcacheWarn = &quot; &quot; \t\t\t\t\tcacheError = &quot; &quot;  \t\t\t\t\ti_debug = 0 \t\t\t\t\ti_info = 0 \t\t\t\t\ti_warn = 0 \t\t\t\t\ti_error = 0 \t\t\t\t\tlog.Print(&quot;\u0411\u0434 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u0430, \u0430 \u043a\u0435\u0448 \u043e\u0447\u0438\u0449\u0435\u043d&quot;)  \t\t\t\tcase &quot;ClearCache&quot;: \t\t\t\t\tcacheDebug = &quot; &quot; \t\t\t\t\tcacheInfo = &quot; &quot; \t\t\t\t\tcacheWarn = &quot; &quot; \t\t\t\t\tcacheError = &quot; &quot; \t\t\t\t\ti_debug = 0 \t\t\t\t\ti_info = 0 \t\t\t\t\ti_warn = 0 \t\t\t\t\ti_error = 0 \t\t\t\t\tlog.Print(&quot;\u041a\u0435\u0448 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0447\u0438\u0441\u0442\u0438\u043b\u0438&quot;)  \t\t\t\tdefault: \t\t\t\t\tlog.Print(&quot;case Default\\n&quot;) \t\t\t\t\tc.Close() \t\t\t\t\treturn \t\t\t\t}  \t\t\t} \t\t}(conn) \t} }  \/\/\u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0448\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. func DebugDB(cache string) { \tDB.Exec(&quot;INSERT INTO debug (date,message) VALUES &quot; + cache) \treturn } func InfoDB(cache string) { \tDB.Exec(&quot;INSERT INTO info (date,message) VALUES &quot; + cache) \treturn } func WarnDB(cache string) { \tDB.Exec(&quot;INSERT INTO warn (date,message) VALUES &quot; + cache) \treturn } func ErrorDB(cache string) { \tDB.Exec(&quot;INSERT INTO error (date,message) VALUES &quot; + cache) \treturn }  \/\/\u0410 \u0442\u0443\u0442 \u043f\u0438\u0448\u0435\u043c \u0432 \u0431\u0434 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c email \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 func FatalDB(message string) { \tDB.Exec(&quot;INSERT INTO fatal (date,message) VALUES (?,?)&quot;, time.Now().String(), message) \tconf := map[string]string{ \t\t&quot;username&quot;: &quot;example@gmail.com&quot;, \/\/\u043b\u043e\u0433\u0438\u043d \u043e\u0442 \u043b\u044e\u0431\u043e\u0439 \u043f\u043e\u0447\u0442\u044b \u043d\u0430 gamail \t\t&quot;password&quot;: &quot;example&quot;,           \/\/\u043d\u0443 \u0438 \u043f\u0430\u0440\u043e\u043b\u044c \t\t&quot;host&quot;:     &quot;smtp.gmail.com&quot;, \t\t&quot;port&quot;:     &quot;587&quot;, \t} \tto := []string{ \t\t&quot;example99@gmail.com&quot;, \t\t&quot;id324237193-6fce7d7ef@vkmessenger.com&quot;, \t} \tSendMail(conf, to, &quot;Fatal Errors&quot;, message) \treturn  } func SendMail(conf map[string]string, to []string, subject string, msg string) { \tauth := smtp.PlainAuth( \t\t&quot;&quot;, \t\tconf[&quot;username&quot;], \t\tconf[&quot;password&quot;], \t\tconf[&quot;host&quot;], \t) \taddress := fmt.Sprintf(&quot;%v:%v&quot;, conf[&quot;host&quot;], conf[&quot;port&quot;]) \tbody := []byte(&quot;Subject: &quot; + subject + &quot;\\r\\n\\r\\n&quot; + msg) \terr := smtp.SendMail( \t\taddress, \t\tauth, \t\tconf[&quot;username&quot;], \t\tto, \t\tbody, \t) \tif err != nil { \t\tlog.Fatal(err) \t} }  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<div class=\"clear\"><\/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\/270035\/\"> http:\/\/habrahabr.ru\/post\/270035\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u042d\u0442\u043e \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0425\u0430\u0431\u0440\u0435, \u043f\u0438\u0448\u0443 \u0435\u0451 \u043f\u043e \u0445\u043e\u0434\u0443 \u0441\u0432\u043e\u0435\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u0417\u0430 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 \u0431\u0443\u0434\u0443 \u043e\u0447\u0435\u043d\u044c \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0435\u043d.<\/p>\n<p>  <a href=\"http:\/\/habrahabr.ru\/post\/98638\/\">\u0417\u0434\u0435\u0441\u044c<\/a> \u0430\u0432\u0442\u043e\u0440 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0438\u043c\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043b\u043e\u0433\u0438. \u0412 \u0441\u0432\u043e\u0435\u043c \u0446\u0438\u043a\u043b\u0435 \u0441\u0442\u0430\u0442\u0435\u0439 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0432\u0430\u043c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0438\u043c\u0438 \u0440\u0443\u043a\u0430\u043c\u0438 \u043d\u0430 GO.<\/p>\n<p>  \u0418\u0442\u0430\u043a \u043d\u0430\u0447\u043d\u0451\u043c. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 tcp \u0441\u0435\u0440\u0432\u0435\u0440:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">tcp \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 golang<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"go\">package main  import (  \t&quot;log&quot; \t&quot;net&quot; )  func main() {  \t\/\/\u0432\u0435\u0448\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 2000 \u043f\u043e\u0440\u0442 \tl, err := net.Listen(&quot;tcp&quot;, &quot;:2000&quot;) \tif err != nil { \t\tlog.Fatal(err) \t} \tdefer l.Close() \tfor { \t\t\/\/\u0412 \u0432\u0435\u0447\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 &quot;\u0441\u043b\u0443\u0448\u0430\u0435\u043c&quot; 2000 \u043f\u043e\u0440\u0442. \u0416\u0434\u0451\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \t\tconn, err := l.Accept() \t\tif err != nil { \t\t\tlog.Fatal(err) \t\t} \t\t\/\/\u041a \u043d\u0430\u043c \u043a\u0442\u043e \u0442\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b\u0441\u044f. \u041e\u0442\u043a\u0440\u043e\u0435\u043c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0441\u0432\u043e\u044e \u0433\u043e\u0440\u0443\u0442\u0438\u043d\u0443 \t\tgo func(c net.Conn) {  \t\t\t\/\/\u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0431\u0443\u0444\u0435\u0440 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0432\u043d\u0435. \t\t\tbuf := make([]byte, 1024)  \t\t\t\/\/\u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0432\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c n \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \t\t\t\/\/ \u0430 \u043d\u0435 \u043e\u0434\u043d\u043e \t\t\tfor { \t\t\t\t\/\/\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u0438\u0448\u0435\u043c \u0432 \u0431\u0443\u0444\u0435\u0440 \t\t\t\tc.Read(buf)  \t\t\t\tlog.Print(string(buf)) \t\t\t} \t\t}(conn) \t} } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0432 \u043d\u043e\u0432\u043e\u043c \u043e\u043a\u043e\u0448\u043a\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430 \u0434\u0435\u043b\u0430\u0435\u043c \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/pp.vk.me\/c629304\/v629304193\/1af0e\/WEg-JKHrFpQ.jpg\" alt=\"image\"\/>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u043c\u0438\u043d\u0438 api.<\/p>\n<p>  \/\/\u0442\u0438\u043f\u044b \u043b\u043e\u0433 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439<br \/>  Debug|][|\u0447\u0442\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043b\u043e\u0433 \u0431\u0443\u0444\u0435\u0440-&gt;150 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<br \/>  Info|][|\u0447\u0442\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043b\u043e\u0433 \u0431\u0443\u0444\u0435\u0440-&gt;100 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<br \/>  Warn|][|\u0447\u0442\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043b\u043e\u0433 \u0431\u0443\u0444\u0435\u0440-&gt;50 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<br \/>  Error|][|\u0447\u0442\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043b\u043e\u0433 \u0431\u0443\u0444\u0435\u0440-&gt;25 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<br \/>  Fatal|][|\u0447\u0442\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043b\u043e\u0433 \u0431\u0443\u0444\u0435\u0440-&gt;0 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/p>\n<p>  \/\/\u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0431\u0443\u0444\u0435\u0440\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u0431\u0434<br \/>  UnloadTheCacheDB|][|null<\/p>\n<p>  \/\/\u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0431\u0443\u0444\u0435\u0440 \u043d\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0431\u0434<br \/>  ClearCache|][|null<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0434:  <\/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-267366","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/267366","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=267366"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/267366\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=267366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=267366"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=267366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}