{"id":178963,"date":"2013-05-07T08:37:03","date_gmt":"2013-05-07T04:37:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=178963"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=178963","title":{"rendered":"<span class=\"post_title\">\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Golang<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0431 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0438 \u0432 \u043a\u043e\u0435\u0439 \u043c\u0435\u0440\u0435 \u043d\u0435 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044e, \u0447\u0442\u043e \u043e\u043d \u043b\u0443\u0447\u0448\u0435 \u0447\u0435\u043c \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0441 \u043d\u0435\u0442\u0435\u0440\u043f\u0435\u043d\u0438\u0435\u043c \u0436\u0434\u0443 \u0432\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 ORM, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e \u0441\u0443\u0442\u0438, \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439 \u0432 \u043d\u0430\u0448\u0438\u0445 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445: <a href=\"http:\/\/sezn.ru\/\">http:\/\/sezn.ru\/<\/a>, <a href=\"http:\/\/hashcode.ru\/\">http:\/\/hashcode.ru\/<\/a> \u0438 <a href=\"http:\/\/careers.hashcode.ru\/\">http:\/\/careers.hashcode.ru\/<\/a>.<\/p>\n<p>  \u042f \u043d\u0430\u0447\u0430\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 <a href=\"http:\/\/careers.hashcode.ru\/\">http:\/\/careers.hashcode.ru\/<\/a> \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0443\u0442\u043e\u0440\u0430 \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434. \u041f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0441\u0430\u0439\u0442\u0430 \u0431\u044b\u043b\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430 \u0435\u0449\u0435 \u0434\u043e \u0432\u044b\u0445\u043e\u0434\u0430 Go RC1. \u041f\u0440\u043e\u0435\u043a\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0438\u0437 \u0432\u0441\u0435\u0445, \u0447\u0442\u043e \u044f \u0437\u043d\u0430\u044e, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043d\u0435 Google.<br \/>   <a name=\"habracut\"><\/a><br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0438\u0437 \u0431\u0430\u0437\u044b. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0425\u044d\u0448\u041a\u043e\u0434 \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c \u0438 \u043e\u0442\u0432\u0435\u0442\u0430\u043c, \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441.<\/p>\n<pre><code class=\"go\">type Question struct { \tId int \tTitle int \tBody string \tTagsStr string \tScore int \tViewCount int    \tTags []Tag  } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u043c\u0435\u0442\u043a\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u0430\u0436\u0434\u044b. \u042d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u043b\u0438\u0448\u043d\u0438\u0439 \u0440\u0430\u0437 \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0430\u043c. <\/p>\n<p>  \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043c\u0435\u0442\u043a\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430.<\/p>\n<pre><code class=\"go\">type Tag struct { \tId int \tUsedCount int \tName string } <\/code><\/pre>\n<p>  \u0412\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043d\u0430 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438\u0434\u0435\u0442 \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0431\u0430\u0437\u044b, \u0430 \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446, \u0442\u043e \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445. (\u0422\u0435\u0441\u0442\u044b \u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.)<\/p>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u044c\u044e\u0448\u043a\u0430, \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 (\u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0430 \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438).<\/p>\n<pre><code class=\"go\">func questionsListHandler(user UserInterface, w http.ResponseWriter, r *http.Request) * BasePage { \tperPage, pageNum, orderBy := pageParams(r) \tctx := make(utils.Context) \tctx[&quot;User&quot;] = user \tctx[\u201cQuestions\u201d] = questionLoader.Load(perPage, (pageNum-1)*perPage, orderBy) \t \treturn &BasePage{ \t\tTitle: QuestionsListPageTitle, \t\tBody: Body{ \t\t\tTemplate: QuestionsListTmpl, \t\t\tData:     ctx, \t\t}, \t} } <\/code><\/pre>\n<p>  \u041d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>Load<\/code>. \u041e\u043d \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0442\u0440\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430: \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0438, \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443. <\/p>\n<pre><code class=\"go\">func (self QuestionLoader) Load(offset, limit int, orderBy string) []*Question { \tdeps, names := self.defaultDependencies() \tqp := makeQueryParam ( \t\tself.selectString(),  \t\tself.fromString(),  \t\tself.were(),  \t\torderBy, limit, offset \t)  \treturn self.toQuestions(LoadDBModelWithCache(qp, self.extractor(),  self.cacheBuilder(), deps, names)) } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 <code>defaultDependencies<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 (\u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0431\u0430\u0437\u044b). \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 <code>Question<\/code> \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b <code>Tag<\/code>.<\/p>\n<pre><code class=\"go\">func (self QuestionLoader) defaultDependencies() (map[string]DepFetcher, []string) { \tdps := make(map[string]DepFetcher) \tdps[tagLoader.tableName()] = TagByQuestionDependenceFetcher  \treturn dps, []string{ tagLoader.tableName() } } <\/code><\/pre>\n<p>  <code>DepFetcher<\/code> \u2014 \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b.<\/p>\n<pre><code class=\"go\">func TagByQuestionDependenceFetcher(value interface{}) { \tvar question *Question \tvar ok bool  \tif question, ok = value.(*Question); !ok { \t\treturn \t}  \tresult := LoadDBModelWithCache(\/* \u0417\u0430\u043f\u0440\u043e\u0441 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u043c\u043e\u0434\u0435\u043b\u0438 Question*\/) \tquestion.Tags = tagLoader.toTags(result) } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434\u044b <code>selectString<\/code> \u0438 <code>fromString<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0441\u0442\u0440\u043e\u043a\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412 \u043d\u0438\u0445 \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e. \u041c\u0435\u0442\u043e\u0434 <code>were<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 <code>WhereParam<\/code>.<\/p>\n<pre><code class=\"go\">type WhereParam struct { \tQuery     string \tWhereAttr []WhereAttr }  type WhereAttr struct { \tName  string \tValue interface{} } <\/code><\/pre>\n<p>  \u0412 \u043f\u043e\u043b\u0435 <code>Query<\/code> \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0430, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0430\u044f \u0437\u0430\u043f\u0440\u043e\u0441. \u0412 <code>WhereAttr<\/code> \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u043f\u043e id.<\/p>\n<pre><code class=\"go\">func (self QuestionLoader) wereById (tblaliase, id int) *WhereParam { \twp := new(WhereParam) \twp.Query = &quot;WHERE &quot; + self.tblaliase() + &quot;.id = @id&quot;  \twp.WhereAttr = []WhereAttr{ \t\tWhereAttr{ \t\t\tName:  &quot;@id&quot;, \t\t\tValue: id, \t\t}, \t}  \treturn wp } <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>makeQueryParam<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0431\u0430\u0437\u0435 \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b <code>QueryParam<\/code>.<\/p>\n<pre><code class=\"go\">type QueryParam struct { \tSelect  string \tFrom    string \tWhere   WhereParam \tOrderBy string \tOffset  string \tLimit   string \tExt     string } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0431\u0430\u0437\u044b:<\/p>\n<pre><code class=\"go\">func LoadDBModelWithCache(qp *QueryParam, \tresultMaker ResultMaker, \tcacheBuilder CacheBuilder, \tdependences map[string]DepFetcher, \tdependencesNames []string) []interface{} {  \tif qp == nil { \t\treturn nil \t}  \tvar results []interface{} = nil \tquery := qp.String() \tparams := qp.Where.WhereAttr  \tsqlQuery := ReplaceParameters(query, params) \tkey := generateMd5Sum(sqlQuery) \tms := GetCacheSystem().GetStore()  \tif cacheBuilder != nil { \t\tcachedBytes := cacheBuilder.Try(sqlQuery, key, params) \t\tif cachedBytes != nil && len(cachedBytes) &gt; 0 { \t\t\tresults = cacheBuilder.Extract(cachedBytes) \t\t\tif results == nil { \t\t\t\tms.Delete(key) \t\t\t} \t\t} \t}  \tif results == nil { \t\tdb, err := sql.Open(postgresDriverName, connection) \t\tHandleDataBaseError(err) \t\tdefer db.Close()  \t\tprepQuery := PrepereQuery(query, params) \t\tprepParams := PrepereQueryParams(params)  \t\trows, err := db.Query(prepQuery, prepParams...) \t\tHandleDataBaseError(err) \t\tif rows != nil { \t\t\tdefer rows.Close() \t\t\tresults = resultMakerDecorator(rows, resultMaker) \t \t\t\tif cacheBuilder != nil { \t\t\t\tms.EasySaveArray(key, results) \t\t\t\tcacheBuilder.Descripe(results, key) \t\t\t} \t\t} else { \t\t\tLogger.Println(&quot;Db query error:&quot; + sqlQuery) \t\t} \t}  \tfor i, _ := range results { \t\tfor _, depname := range dependencesNames { \t\t\tfatcher := dependences[depname] \t\t\tif fatcher != nil { \t\t\t\tfatcher(results[i]) \t\t\t} \t\t} \t}  \treturn results } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0431\u044a\u0435\u043c\u043d\u044b\u0439, \u043f\u043e\u0439\u0434\u0435\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443. \u041d\u0430 \u0432\u0445\u043e\u0434\u0435 \u043c\u044b \u0438\u043c\u0435\u0435\u043c: \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 c \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0435, \u043c\u0435\u0442\u043e\u0434, \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430, \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u043a\u044d\u0448\u0430, \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0438 \u0438\u0445 \u0438\u043c\u0435\u043d\u0430.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0437\u0430\u043c\u0435\u043d\u044f\u044f \u043f\u0441\u0435\u0432\u0434\u043e\u043d\u0438\u043c\u044b \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043a\u043b\u044e\u0447 \u043a \u043a\u044d\u0448\u0443 (\u0437\u0430 \u043e\u0434\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043b\u043e\u0433 \u043e\u0442\u043b\u0430\u0434\u043a\u0438).<\/p>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u043a\u043b\u044e\u0447, \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 <code>memcached<\/code>. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0441\u043f\u0435\u0445\u0430, \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u0442, \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0431\u0430\u0437\u044b, \u0437\u0430\u043d\u043e\u0441\u0438\u043c \u0438\u0445 \u0432 \u043a\u044d\u0448. <\/p>\n<p>  \u041d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0448\u0430\u0433\u0435 \u043c\u044b \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438. \u0417\u0434\u0435\u0441\u044c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0434\u0432\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u041f\u0435\u0440\u0432\u043e\u0435 \u2014 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 \u0431\u0430\u0437\u044b \u043d\u0438\u0447\u0435\u043c \u043d\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043a\u044d\u0448\u0430, \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440. \u0412\u0442\u043e\u0440\u043e\u0435 \u2014 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430 \u043e\u0434\u043d\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439, \u043d\u043e \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445. <\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u044f\u0447\u0435\u0435\u043a \u0431\u0430\u0437\u044b (<code>ResultMaker<\/code>):<\/p>\n<pre><code class=\"go\">func tagFromResultSet (rows * sql.Rows) interface{} { \tt := Tag{} \terr := rows.Scan(&t.Id, &t.Name) \tHandleDataBaseError(err)  \treturn t } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u043d\u044e\u0430\u043d\u0441\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430.<\/p>\n<pre><code class=\"go\">func (self * QuestionLoader) toQuestions(queryResult []interface{}) []*Questions{ \tif queryResult == nil { return nil } \tqrLen := len(queryResult)  \tif qrLen &lt;= 0 { return nil }  \t \tresultSet := make([]*Questions, qrLen)  \tfor index, result := range queryResult {\t\t \t\tif val, ok := result.(*Questions); ok { \t\t\tresultSet[index] = val \t\t} else { \t\t\tresultSet[index] = &Questions{} \t\t} \t \t} \treturn resultSet } <\/code><\/pre>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u043e\u0441\u0442\u0435 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043a\u0440\u0430\u0442\u043a\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c, \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u0411\u0443\u0434\u0443 \u0440\u0430\u0434 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u0430\u0448\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043a \u043f\u043e\u0441\u0442\u0443 \u0438\u043b\u0438 <a href=\"http:\/\/hashcode.ru\/questions\/tagged\/go\/\">\u0432 \u0432\u0435\u0442\u043a\u0435 \u043f\u043e Go \u043d\u0430 \u0425\u044d\u0448\u041a\u043e\u0434\u0435<\/a>.    \t \t\t   \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\/178963\/\"> http:\/\/habrahabr.ru\/post\/178963\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0431 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0438 \u0432 \u043a\u043e\u0435\u0439 \u043c\u0435\u0440\u0435 \u043d\u0435 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044e, \u0447\u0442\u043e \u043e\u043d \u043b\u0443\u0447\u0448\u0435 \u0447\u0435\u043c \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0441 \u043d\u0435\u0442\u0435\u0440\u043f\u0435\u043d\u0438\u0435\u043c \u0436\u0434\u0443 \u0432\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 ORM, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e \u0441\u0443\u0442\u0438, \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439 \u0432 \u043d\u0430\u0448\u0438\u0445 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445: <a href=\"http:\/\/sezn.ru\/\">http:\/\/sezn.ru\/<\/a>, <a href=\"http:\/\/hashcode.ru\/\">http:\/\/hashcode.ru\/<\/a> \u0438 <a href=\"http:\/\/careers.hashcode.ru\/\">http:\/\/careers.hashcode.ru\/<\/a>.<\/p>\n<p>  \u042f \u043d\u0430\u0447\u0430\u043b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 <a href=\"http:\/\/careers.hashcode.ru\/\">http:\/\/careers.hashcode.ru\/<\/a> \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0443\u0442\u043e\u0440\u0430 \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434. \u041f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0441\u0430\u0439\u0442\u0430 \u0431\u044b\u043b\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430 \u0435\u0449\u0435 \u0434\u043e \u0432\u044b\u0445\u043e\u0434\u0430 Go RC1. \u041f\u0440\u043e\u0435\u043a\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0438\u0437 \u0432\u0441\u0435\u0445, \u0447\u0442\u043e \u044f \u0437\u043d\u0430\u044e, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043d\u0435 Google.   <\/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-178963","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/178963","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=178963"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/178963\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=178963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=178963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=178963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}