{"id":459856,"date":"2025-05-16T09:01:59","date_gmt":"2025-05-16T09:01:59","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=459856"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=459856","title":{"rendered":"<span>\u0412 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u0441\u0442\u0438\u043b\u044f. \u0427\u0430\u0441\u0442\u044c 2. \u041f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 \u043b\u0438\u043d\u0442\u0435\u0440 \u043d\u0430 Go \u0434\u043b\u044f golangci-lint<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u0440\u0442\u0451\u043c \u0411\u043b\u043e\u0445\u0438\u043d, \u044f Go-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0439 \u041e\u0441\u0442\u0440\u043e\u0432\u043a\u0430. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043b\u0438\u043d\u0442\u0438\u043d\u0433\u0435 \u043a\u043e\u0434\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0431\u044b \u00ab\u0421\u0443\u043c\u0435\u0440\u043a\u0438\u00bb \u0431\u044b\u043b\u0438 \u043f\u0440\u043e \u043a\u043e\u0434, \u042d\u0434\u0432\u0430\u0440\u0434 \u2014 \u0431\u044b\u043b \u043b\u0438\u043d\u0442\u0435\u0440\u043e\u043c, \u0430 \u0411\u0435\u043b\u043b\u0430 \u2014 \u043b\u0435\u0433\u0430\u0441\u0438-\u043a\u043e\u0434\u043e\u043c, \u0438\u0445 \u0434\u0438\u0430\u043b\u043e\u0433 \u0437\u0432\u0443\u0447\u0430\u043b \u0431\u044b \u0442\u0430\u043a:<\/p>\n<blockquote>\n<p>\u2014 \u041b\u0438\u043d\u0442\u0435\u0440 \u0441\u043c\u043e\u0442\u0440\u0435\u043b \u043d\u0430 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0441 \u0431\u043e\u043b\u044c\u044e \u0438 \u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435\u043c.<br \/>\u2014 \u041a\u0430\u043a\u0430\u044f \u0433\u043b\u0443\u043f\u0430\u044f, \u0437\u0430\u0431\u044b\u0442\u0430\u044f \u0432\u0441\u0435\u043c\u0438 \u043a\u043e\u0434\u043e\u0432\u0430\u044f \u0431\u0430\u0437\u0430.<br \/>\u2014 \u041d\u0443, \u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0437\u044f\u043b\u0441\u044f \u0435\u0451 \u0447\u0438\u043d\u0438\u0442\u044c, \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0430\u0437\u043e\u0445\u0438\u0441\u0442.<\/p>\n<\/blockquote>\n<p>\u041b\u044e\u0431\u043e\u0439, \u043a\u0442\u043e \u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u0442\u0430\u0440\u043e\u043c \u043a\u043e\u0434\u0435 \u0431\u0435\u0437 \u0441\u0442\u0430\u0442\u0438\u043a\u0438, \u0437\u043d\u0430\u0435\u0442: \u0447\u0435\u043c \u0433\u043b\u0443\u0431\u0436\u0435 \u043a\u043e\u043f\u0430\u0435\u0448\u044c, \u0442\u0435\u043c \u0441\u0442\u0440\u0430\u0448\u043d\u0435\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f. \u0412 <a href=\"https:\/\/habr.com\/ru\/companies\/ostrovok\/articles\/839514\/\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043b\u0438\u043d\u0442\u0435\u0440\u044b \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0440\u0430 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u2014 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043b\u0438\u043d\u0442\u0435\u0440 \u0438 \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0435\u0433\u043e \u0432 <code>golangci-lint<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0441\u0430\u043c \u0432\u044b\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430.<\/p>\n<h3>Disclaimer<\/h3>\n<p>\u041b\u0438\u043d\u0442\u0435\u0440 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0431\u044a\u0451\u043c\u043d\u044b\u0439 (200+ \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430), \u0438 \u0435\u0441\u043b\u0438 \u0431\u044b \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0437\u0430\u043f\u0438\u0445\u043d\u0443\u0442\u044c \u0432\u0441\u0451 \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0430\u0442\u044c\u044e, \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0436\u0435\u0441\u0442\u043e\u043a\u043e \u2014 \u0438 \u0434\u043b\u044f \u0432\u0430\u0441, \u0438 \u0434\u043b\u044f \u043c\u043e\u0435\u0439 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 <strong>\u0432 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/strong> \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438.\u00a0<\/p>\n<p>\u041f\u0440\u0438\u0441\u0442\u0451\u0433\u0438\u0432\u0430\u0439\u0442\u0435\u0441\u044c, \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e!<\/p>\n<h2>\u041a\u0430\u043a \u0440\u043e\u0434\u0438\u043b\u0441\u044f ProperOrder, \u0438\u043b\u0438 \u00ab\u0440\u0430\u0437\u043e\u0440\u0432\u0430\u0442\u044c \u0441\u0435\u043c\u0435\u0439\u043d\u044b\u0435 \u0443\u0437\u044b\u00bb<\/h2>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u043f\u0438\u0441\u0430\u0442\u044c \u043b\u0438\u043d\u0442\u0435\u0440, \u044f \u0434\u043e\u043b\u0433\u043e \u043b\u043e\u043c\u0430\u043b \u0433\u043e\u043b\u043e\u0432\u0443: \u043a\u0430\u043a\u043e\u0439 \u043a\u0435\u0439\u0441 \u0432\u0437\u044f\u0442\u044c? \u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c, \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 \u043d\u0430\u0448 \u043d\u043e\u0432\u044b\u0439 \u043b\u0438\u043d\u0442\u0435\u0440 \u2014 <code>ProperOrder<\/code>.<\/p>\n<h3>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 ProperOrder?<\/h3>\n<p>\u041e\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e \u043a\u043e\u0434 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0432 \u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435:<\/p>\n<ul>\n<li>\n<p>\u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0442\u043e\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 (\u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c);<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0442\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b.<\/p>\n<\/li>\n<\/ul>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043a\u043e\u0434\u0430 \u0438 \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439. \u042d\u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0432\u043e\u0441\u043f\u0440\u0438\u044f\u0442\u0438\u0435 \u0438 \u043a\u0430\u043a <code>ProperOrder<\/code> \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0435\u0433\u043e \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0442\u044c.<\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440 1 (\u043d\u0435\u0443\u0434\u0430\u0447\u043d\u044b\u0439)<\/strong>:<\/p>\n<pre><code class=\"go\">type Man struct {...}  type Woman struct {...}  func (m Man) GetName() string {...}  func (w Woman) GetName() string {...}<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u0435\u0442\u043e\u0434 <code>GetName<\/code> \u0434\u043b\u044f <code>Man<\/code> \u0440\u0430\u0437\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b <code>Woman<\/code>. \u041a\u043e\u0433\u0434\u0430 \u043a\u043e\u0434 \u0440\u0430\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u0441\u043d\u0438\u0436\u0430\u044e\u0442 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c.<\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440 2 (\u0443\u0434\u0430\u0447\u043d\u044b\u0439)<\/strong>:<\/p>\n<pre><code class=\"go\">type Man struct {...}  func (m Man) GetName() string {...}  type Woman struct {...}  func (w Woman) GetName() string {...}<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0451 \u043b\u043e\u0433\u0438\u0447\u043d\u043e: \u043e\u0431\u044a\u044f\u0432\u0438\u043b\u0438 <code>Man<\/code>, \u0437\u0430\u0442\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434.<\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0440\u0443\u0448\u0430\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a?<\/h4>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f <strong>\u043d\u0435 \u0441\u0442\u0440\u043e\u0433\u043e \u0434\u0440\u0443\u0433 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u043c<\/strong>, \u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"go\">type Man struct {...}  type Health struct {...}  func NewMan(h Health) Man {..}  type Woman struct {...}  func (m Man) FindLove(w []Woman) (Woman) {...}<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043a\u043e\u0434\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 <code>Health<\/code> \u0438\u0434\u0451\u0442 <strong>\u0434\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 <\/strong><code>NewMan<\/code>, \u0445\u043e\u0442\u044f \u0441\u0430\u043c <code>Man<\/code> \u0443\u0436\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d. \u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e <code>Health<\/code> <strong>\u043d\u0443\u0436\u0435\u043d \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430<\/strong>.<\/p>\n<p>\u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0441 <code>FindLove<\/code>: \u0437\u0434\u0435\u0441\u044c \u043c\u0430\u0441\u0441\u0438\u0432 <code>[]Woman<\/code> \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043c\u0435\u0442\u043e\u0434\u0430 <code>Man<\/code>, \u0430 \u0441\u0430\u043c \u043c\u0435\u0442\u043e\u0434 <strong>\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <\/strong><code>Woman<\/code>. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043b\u0438\u043d\u0442\u0435\u0440 <strong>\u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0443\u0433\u0430\u0442\u044c\u0441\u044f<\/strong>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043b\u043e\u0433\u0438\u0447\u0435\u043d: <strong>\u0422\u0438\u043f\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0438\u043b\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445, \u043c\u043e\u0433\u0443\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0440\u0430\u043d\u044c\u0448\u0435.<\/strong><\/p>\n<h2>\u0410 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0434\u043b\u044f \u043b\u0438\u043d\u0442\u0435\u0440\u0430?<\/h2>\n<p>\u041e\u0434\u043d\u0430 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u0443\u0442\u0438 \u2014 \u044d\u0442\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0447\u0451\u0442\u043a\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430 \u0438\u043b\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043b\u0438\u043d\u0442\u0435\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c. \u0418\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0443\u0436\u0438\u0445 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432 \u0432 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043d\u0435 \u0434\u0430\u0432\u0430\u043b\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.<\/p>\n<p>\u041f\u043e\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u0444\u0430\u043a\u0442: \u0434\u0430\u0436\u0435 \u043b\u0438\u043d\u0442\u0435\u0440\u044b, \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u0438 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u043d\u0435\u0440\u0435\u0434\u043a\u043e \u0441\u0442\u0440\u0430\u0434\u0430\u044e\u0442 \u043e\u0442 \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0438 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b. \u042d\u0442\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u043c \u0431\u0430\u0440\u044c\u0435\u0440\u043e\u043c \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u0433\u043b\u0443\u0431\u0436\u0435 \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0437\u0431\u043e\u0440 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u044b. \u041e\u0442\u0441\u044e\u0434\u0430 \u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043b\u0438\u043d\u0442\u0435\u0440\u043e\u0432, \u0443\u0434\u0435\u043b\u044f\u044f \u043e\u0441\u043e\u0431\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438, \u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 <code>user-friendly<\/code> \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/186\/675\/f64\/186675f645dd8afdef476f77eb310c45.png\" width=\"994\" height=\"622\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/186\/675\/f64\/186675f645dd8afdef476f77eb310c45.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/186\/675\/f64\/186675f645dd8afdef476f77eb310c45.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041a\u0430\u043a \u0438\u0442\u043e\u0433, \u044f \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u0442\u0430\u043a\u043e\u043c\u0443 \u0432\u0438\u0434\u0443:<\/p>\n<pre><code>\u251c\u2500\u2500 analyzers \u2502   \u2514\u2500\u2500 custom_linter \u2502       \u251c\u2500\u2500 analyzer.go \u2502       \u251c\u2500\u2500 analyzer_test.go \u2502       \u2514\u2500\u2500 testdata \u2502           \u2514\u2500\u2500 src \u2502               \u2514\u2500\u2500 src.go \u251c\u2500\u2500 cmd \u2502   \u2514\u2500\u2500 custom_linter \u2502       \u2514\u2500\u2500 main.go \u2502\u2500\u2500 internal \u2502   \u2514\u2500\u2500 tests \u2502       \u2514\u2500\u2500 tests.go \u2514\u2500\u2500 plugin     \u2514\u2500\u2500 main.go<\/code><\/pre>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435:<\/p>\n<pre><code>analyzers\/        \u2014 \u0437\u0434\u0435\u0441\u044c \u0436\u0438\u0432\u0451\u0442 \u0432\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043b\u0438\u043d\u0442\u0435\u0440\u0430   \u251c\u2500\u2500 analyzer.go        \u2014 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043a\u043e\u0434\u0430   \u251c\u2500\u2500 analyzer_test.go   \u2014 \u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u043b\u0438\u043d\u0442\u0435\u0440\u0430   \u2514\u2500\u2500 testdata\/          \u2014 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043b\u0438\u043d\u0442\u0435\u0440                              (\u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438 \u0442\u043e,                                                \u0447\u0442\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0443\u0433\u0430\u0442\u044c) cmd\/              \u2014 \u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430   \u2514\u2500\u2500 main.go           \u2014 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043b\u0438\u043d\u0442\u0435\u0440 (\u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u043e\u0433\u043d\u0430\u0442\u044c \u0435\u0433\u043e                                            \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0442 golangci-lint) internal\/         \u2014 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0437\u0430\u0434\u0430\u0447   \u2514\u2500\u2500 tests.go          \u2014 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 plugin\/           \u2014 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043b\u0438\u043d\u0442\u0435\u0440\u0430 \u0432 golangci-lint   \u2514\u2500\u2500 main.go<\/code><\/pre>\n<h3>\u0417\u0430\u043f\u0443\u0441\u043a \u043b\u0438\u043d\u0442\u0435\u0440\u0430<\/h3>\n<pre><code class=\"go\">package main  import (   \"golang.org\/x\/tools\/go\/analysis\/singlechecker\"   \"gitlab.com\/common\/linter\/analyzers\/properorder\" )  func main() {   singlechecker.Main(properorder.New()) }<\/code><\/pre>\n<p><code>singlechecker.Main(properorder.New())<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0434\u043b\u044f \u043b\u0438\u043d\u0442\u0435\u0440\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c <strong>\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u043d\u0442\u0435\u0440\u043e\u0432<\/strong>, \u0432\u043c\u0435\u0441\u0442\u043e <code>singlechecker<\/code> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>multichecker.Main()<\/code>.<\/p>\n<h2>\u041b\u0438\u043d\u0442\u0435\u0440, \u0438\u043b\u0438 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u041f\u0440\u043e\u043c\u0435\u0442\u0435\u0439<\/h2>\n<p>\u041a\u043e\u0434 \u0440\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0438\u0434\u0435\u0438. \u041a\u0430\u043a\u0430\u044f \u0443 \u043d\u0430\u0441 \u0438\u0434\u0435\u044f? <strong>\u041f\u043e\u0440\u044f\u0434\u043e\u043a<\/strong>.<br \/>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 <code>ProperOrder<\/code>, \u2014 <strong>\u043a\u0430\u043a \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0437\u0430 \u0447\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442?<\/strong><\/p>\n<p>\u041a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>GetName<\/code> \u0434\u043b\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b <code>Man<\/code>, \u0433\u0434\u0435-\u0442\u043e <strong>\u0432\u044b\u0448\u0435<\/strong> \u0443\u0436\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 \u044d\u0442\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430? \u0418\u043b\u0438 \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c <code>NewPerson<\/code> \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0434\u0451\u0442 <code>type Person struct {}<\/code>?<\/p>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043f\u0440\u043e\u0441\u0442: \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c<strong> <\/strong><code>\u0441\u0442\u0435\u043a<\/code>. \u041d\u043e \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2013 \u0441\u0442\u0435\u043a \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0449\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b.<\/p>\n<h3>\u0421\u0442\u0435\u043a \u2014 \u043a\u043b\u044e\u0447 \u043a \u043f\u043e\u0440\u044f\u0434\u043a\u0443<\/h3>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043b\u0438\u043d\u0442\u0435\u0440 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0444\u0430\u0439\u043b, \u043e\u043d \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 <strong>\u0432\u0430\u0436\u043d\u044b\u0435 \u0443\u0437\u043b\u044b<\/strong> \u0432 \u0441\u0442\u0435\u043a \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0435\u043d \u043b\u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a.<\/p>\n<p><strong>\u0427\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u0441\u0442\u0435\u043a\u0435?<\/strong><\/p>\n<ul>\n<li>\n<p><code>ast.FuncDecl<\/code> \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b (<code>func Foo()<\/code> \u0438\u043b\u0438 <code>func (r *Receiver) Foo()<\/code>);<\/p>\n<\/li>\n<li>\n<p><code>ast.TypeSpec<\/code> \u2014 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 (<code>type Man struct{}<\/code>).<\/p>\n<\/li>\n<\/ul>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 1 \u0438 \u043f\u0440\u043e\u0439\u0434\u0451\u043c\u0441\u044f \u043f\u043e \u043a\u043e\u0434\u0443 \u0441\u0432\u0435\u0440\u0445\u0443-\u0432\u043d\u0438\u0437, \u043f\u043e\u043f\u0443\u0442\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044f \u0432 \u0441\u0442\u0435\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ce0\/f85\/a69\/ce0f85a69de5568ca9ba0d1c53061cf7.png\" width=\"1600\" height=\"1183\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/ce0\/f85\/a69\/ce0f85a69de5568ca9ba0d1c53061cf7.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ce0\/f85\/a69\/ce0f85a69de5568ca9ba0d1c53061cf7.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0427\u0442\u043e \u0436\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c? \u041a\u0440\u0430\u0441\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u0442\u0435\u043a\u0430 (\u043c\u0435\u0442\u043e\u0434 <code>Man<\/code>) \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0438\u0436\u0435\u043b\u0435\u0436\u0430\u0449\u0435\u043c\u0443 (\u0442\u0438\u043f <code>Woman<\/code>). <\/p>\n<h2>\u041a\u0430\u043a ProperOrder \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0434?<\/h2>\n<p>\u0412\u0435\u0441\u044c \u0430\u043d\u0430\u043b\u0438\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>run()<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430. <code>run()<\/code> \u2014 \u044d\u0442\u043e <strong>\u0441\u0435\u0440\u0434\u0446\u0435 \u043b\u0438\u043d\u0442\u0435\u0440\u0430<\/strong>. \u0418\u043c\u0435\u043d\u043d\u043e \u043e\u043d\u0430 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 AST, \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0438 \u0432\u044b\u0437\u043e\u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a.<\/p>\n<p>\u041d\u043e \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>run()<\/code>, \u043d\u0443\u0436\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043b\u0438\u043d\u0442\u0435\u0440:<\/p>\n<pre><code class=\"go\">package properoder  import \"golang.org\/x\/tools\/go\/analysis\"  func New() *analysis.Analyzer {   return &amp;analysis.Analyzer{     Name:     \"properorder\",     Doc:      \"short documentation about linter\",     Run:      run,     URL:      \"https:\/\/documentation.com\",     Requires: []*analysis.Analyzer{inspect.Analyzer},   } }<\/code><\/pre>\n<p>\u0423\u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u043d\u0438\u043c:<\/p>\n<ul>\n<li>\n<p><code>Name<\/code> \u2013 \u0438\u043c\u044f \u043b\u0438\u043d\u0442\u0435\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p><code>Doc<\/code> \u2013 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043b\u0438\u043d\u0442\u0435\u0440\u0430 (\u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u0438 \u0442.\u0434.). \u0414\u043b\u0438\u043d\u043d\u044b\u043c \u0431\u044b\u0442\u044c \u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p><code>Run<\/code> \u2013 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043b\u0438\u043d\u0442\u0435\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p><code>URL<\/code> \u2013 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043b\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u043e\u043b\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e.<\/p>\n<\/li>\n<li>\n<p><code>Requires<\/code> \u2013 \u043d\u0435\u043a\u0430\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f: <code>golangci-lint<\/code> \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 <code>inspect.Analyzer<\/code> \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u0432 (\u043d\u0430\u0448\u0438\u0445 \u043b\u0438\u043d\u0442\u0435\u0440\u043e\u0432). \u0422\u043e \u0435\u0441\u0442\u044c, \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043b\u0438\u043d\u0442\u0435\u0440\u0430 \u0437\u0430\u043d\u043e\u0432\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c AST-\u0434\u0435\u0440\u0435\u0432\u043e.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 run()?<\/h3>\n<pre><code class=\"go\">func run(pass *analysis.Pass) (any, error) {   var lastFile *token.File   v := validator{     Pass: pass,     Stack: stack.New(),   }<\/code><\/pre>\n<p><code>pass *analysis.Pass<\/code> \u2014 \u043e\u0431\u044a\u0435\u043a\u0442, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 <strong>\u0432\u0441\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u043e\u0434\u0435<\/strong> (\u0444\u0430\u0439\u043b\u044b, \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0443\u0437\u043b\u043e\u0432 \u0438 \u0442. \u0434.).<\/p>\n<p><code>validator<\/code> \u2014 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432 \u043b\u0438\u043d\u0442\u0435\u0440\u0435. \u0412 \u043d\u0435\u0439 \u0435\u0441\u0442\u044c:<\/p>\n<ul>\n<li>\n<p><code>Pass<\/code> \u2014 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <code>analysis.Pass<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>Stack<\/code> \u2014 <strong>\u0441\u0442\u0435\u043a \u0443\u0437\u043b\u043e\u0432<\/strong> AST, \u0433\u0434\u0435 \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c, \u043a\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0443\u0436\u0435 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u043b\u0438\u0441\u044c.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041a\u0430\u043a\u0438\u0435 \u0443\u0437\u043b\u044b \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442?<\/h3>\n<pre><code class=\"go\">nodeTypes := []ast.Node{   (*ast.FuncDecl)(nil), \/\/ func Foo() or func (r *Receiver) Foo()   (*ast.TypeSpec)(nil), \/\/ type smt (e.g. struct, int, array etc) }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b <strong>\u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u043c AST<\/strong> \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u043c, \u0447\u0442\u043e \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 <strong>\u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/strong>.<\/p>\n<h3>\u041a\u0430\u043a run() \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0434?<\/h3>\n<p>\u041f\u0440\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>enterNode()<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0435\u0448\u0430\u0435\u0442, \u0447\u0442\u043e \u0441 \u043d\u0438\u043c \u0434\u0435\u043b\u0430\u0442\u044c:<\/p>\n<pre><code class=\"go\">enterNode := func(n ast.Node) bool {   currentFile := pass.Fset.File(n.Pos())    if lastFile == nil || currentFile != lastFile {     v.flushStack() \/\/ \u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u0441\u0442\u0435\u043a\u0430 \u043f\u0440\u0438 \u0441\u043c\u0435\u043d\u0435 \u0444\u0430\u0439\u043b\u0430   }   lastFile = currentFile<\/code><\/pre>\n<p><strong>\u0415\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0448\u043b\u0438 \u0432 \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b<\/strong> \u2014 <strong>\u043e\u0447\u0438\u0449\u0430\u0435\u043c \u0441\u0442\u0435\u043a<\/strong>. \u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043b\u0438\u043d\u0442\u0435\u0440 \u043d\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 <strong>\u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432<\/strong>.<\/p>\n<h3>\u041a\u0430\u043a enterNode() \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0443\u0437\u043b\u044b?<\/h3>\n<pre><code class=\"go\">switch node := n.(type) { case *ast.TypeSpec:   v.CheckTypeSpecPosition(node) \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0433\u0434\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u0442\u0438\u043f   v.Stack.Push(node)             \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u0432 \u0441\u0442\u0435\u043a  case *ast.FuncDecl:   v.TraverseStack(node)         \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043c\u0435\u0442\u043e\u0434\u043e\u0432   v.Stack.Push(node)             \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u0432 \u0441\u0442\u0435\u043a }<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 <strong>\u044d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 (<\/strong><code>TypeSpec<\/code><strong>)<\/strong> \u2013 <strong>\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0451 \u043f\u043e\u0440\u044f\u0434\u043e\u043a<\/strong> \u0438 \u043a\u043b\u0430\u0434\u0451\u043c \u0432 \u0441\u0442\u0435\u043a.<\/p>\n<p>\u0415\u0441\u043b\u0438 <strong>\u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 (<\/strong><code>FuncDecl<\/code><strong>)<\/strong> \u2013 <strong>\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0441\u0442\u043e\u0438\u0442 \u043b\u0438 \u043e\u043d\u0430 \u043d\u0430 \u0441\u0432\u043e\u0451\u043c \u043c\u0435\u0441\u0442\u0435<\/strong>, \u0437\u0430\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0441\u0442\u0435\u043a.<\/p>\n<h3>\u041a\u0430\u043a \u043b\u0438\u043d\u0442\u0435\u0440 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043f\u043e AST?<\/h3>\n<pre><code class=\"go\">inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) inspect.WithStack(nodeTypes, func(n ast.Node, push bool, stack []ast.Node) (proceed bool) {   if push {     return enterNode(n) \/\/ \u0410\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0443\u0437\u0435\u043b   }   return true })<\/code><\/pre>\n<p><code>WithStack<\/code> <strong>\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043f\u043e AST<\/strong>, \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 <strong>\u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u044b\u0435 \u0443\u0437\u043b\u044b<\/strong> (<code>TypeSpec<\/code>, <code>FuncDecl<\/code>) \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>enterNode()<\/code> \u0434\u043b\u044f \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<p>push bool \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442:<\/p>\n<ul>\n<li>\n<p><code>true<\/code> \u2013 \u043c\u044b <strong>\u0432\u043e\u0448\u043b\u0438 \u0432 \u0443\u0437\u0435\u043b<\/strong>, \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e (<code>enterNode(n)<\/code>);<\/p>\n<\/li>\n<li>\n<p><code>false<\/code> \u2013 \u043c\u044b <strong>\u0432\u044b\u0448\u043b\u0438 \u0438\u0437 \u0443\u0437\u043b\u0430<\/strong>, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u043e\u0431\u0445\u043e\u0434.<\/p>\n<\/li>\n<\/ul>\n<p><code>Proceed = true<\/code>, \u043c\u044b \u0441\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u0441\u044f \u0433\u043b\u0443\u0431\u0436\u0435 \u0432 ast, <code>= false<\/code>, \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u043c \u043e\u0431\u0445\u043e\u0434 \u0443\u0437\u043b\u0430.<\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"go\">func run(pass *analysis.Pass) (any, error) {   var lastFile *token.File   v := validator{     Pass: pass,     Stack: stack.New(),   }    nodeTypes := []ast.Node{     (*ast.FuncDecl)(nil), \/\/ func Foo() or func (r *Receiver) Foo()     (*ast.TypeSpec)(nil), \/\/ type smt (e.g. struct, int, array etc)   }   enterNode := func(n ast.Node) bool {     currentFile := pass.Fset.File(n.Pos())     if lastFile == nil || currentFile != lastFile {       v.flushStack()     }     lastFile = currentFile      switch node := n.(type) {     case *ast.TypeSpec:       v.CheckTypeSpecPosition(node)       v.Stack.Push(node)     case *ast.FuncDecl:       v.TraverseStack(node)       v.Stack.Push(node)     }     return false   }    inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)   inspect.WithStack(nodeTypes, func(n ast.Node, push bool, stack []ast.Node) (proceed bool) {     if push {       return enterNode(n)     }     return true   })    return nil, nil }<\/code><\/pre>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0441\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c. \u041f\u043e\u0447\u0435\u043c\u0443? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u0431\u0443\u0434\u0443\u0442 \u043b\u0438\u0448\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u0438. \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c.<\/p>\n<h2>\u0420\u0430\u0437 \u043c\u043d\u0435 \u043d\u0435 \u0434\u0430\u043d\u043e \u0432\u0441\u0435\u043b\u044f\u0442\u044c \u043b\u044e\u0431\u043e\u0432\u044c, \u044f \u0431\u0443\u0434\u0443 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u0445<\/h2>\n<p>\u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0432\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0432 AST, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430\u0448 \u043b\u0438\u043d\u0442\u0435\u0440:<\/p>\n<ul>\n<li>\n<p><code>ast.FuncDecl<\/code> \u2014 \u0443\u0437\u043b\u044b, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b;<\/p>\n<\/li>\n<li>\n<p><code>ast.TypeSpec<\/code> \u2014 \u0443\u0437\u043b\u044b, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c ast.FuncDecl (\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b)<\/h3>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code class=\"go\">func (m Man) MakeItGreatAgain(a int, b float64) (enemy int, err error) {..}<\/code><\/pre>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 <code>FuncDecl<\/code> \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430 <code>go\/ast<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"go\">FuncDecl struct {   Doc  *CommentGroup \/\/ associated documentation; or nil   Recv *FieldList    \/\/ receiver (methods); or nil (functions)   Name *Ident        \/\/ function\/method name   Type *FuncType     \/\/ function signature: type and value parameters, results, and position of \"func\" keyword   Body *BlockStmt    \/\/ function body; or nil for external (non-Go) function }<\/code><\/pre>\n<p>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/216\/b9c\/3de\/216b9c3dea3fa3eaaac7a1ece10d7908.png\" width=\"1600\" height=\"460\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/216\/b9c\/3de\/216b9c3dea3fa3eaaac7a1ece10d7908.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/216\/b9c\/3de\/216b9c3dea3fa3eaaac7a1ece10d7908.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u044b:<\/p>\n<ul>\n<li>\n<p>\u0435\u0441\u043b\u0438 <code>Recv = nil<\/code>, \u0437\u043d\u0430\u0447\u0438\u0442, \u044d\u0442\u043e <strong>\u043e\u0431\u044b\u0447\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/strong>;<\/p>\n<\/li>\n<li>\n<p>\u0435\u0441\u043b\u0438 <code>Recv != nil<\/code>, \u0437\u043d\u0430\u0447\u0438\u0442, \u044d\u0442\u043e <strong>\u043c\u0435\u0442\u043e\u0434<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c ast.TypeSpec (\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432)<\/h3>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430:<\/p>\n<pre><code class=\"go\">type Person[T any] = struct {    Name string   Age  int   }<\/code><\/pre>\n<p>\u041e\u043d\u0430 \u0432 AST \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043a\u0430\u043a <code>TypeSpec<\/code>:<\/p>\n<pre><code class=\"go\">TypeSpec struct {   Doc        *CommentGroup  \/\/ associated documentation; or nil   Name       *Ident         \/\/ type name   TypeParams *FieldList     \/\/ type parameters; or nil   Assign     token.Pos      \/\/ position of '=', if any   Type       Expr           \/\/ *Ident, *ParenExpr, *SelectorExpr, *StarExpr, or any of the *XxxTypes   Comment    *CommentGroup  \/\/ line comments; or nil }<\/code><\/pre>\n<p>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f: <\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/86f\/a84\/3b3\/86fa843b36bdd7fd2465ea370788249c.png\" width=\"1544\" height=\"620\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/86f\/a84\/3b3\/86fa843b36bdd7fd2465ea370788249c.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/86f\/a84\/3b3\/86fa843b36bdd7fd2465ea370788249c.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0427\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0441:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u043b\u0435 <code>Type<\/code> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a \u043a\u0430\u043a\u043e\u043c\u0443 \u0442\u0438\u043f\u0443 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <strong>\u044d\u0442\u043e<\/strong> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0438\u043f;<\/p>\n<\/li>\n<li>\n<p>\u043b\u0438\u043d\u0442\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c<strong> <\/strong><code>Name<\/code><strong> \u0438 <\/strong><code>Type<\/code><strong>, <\/strong>\u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a.<\/p>\n<\/li>\n<\/ul>\n<h2>\u041f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u043d\u0430 \u0437\u0430\u043f\u0430\u0434. \u041a\u043e\u0440\u043e\u043b\u044c \u043f\u043e\u0440\u044f\u0434\u043a\u0430<\/h2>\n<p>\u041d\u0430\u0448 \u043b\u0438\u043d\u0442\u0435\u0440 \u043d\u0430\u0443\u0447\u0438\u043b\u0441\u044f \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u043a\u043e\u0434, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432, \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0440\u0430 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, <strong>\u043a\u0430\u043a \u043e\u043d \u0441\u043b\u0435\u0434\u0438\u0442 \u0437\u0430 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439<\/strong>.<\/p>\n<h3>\u041a\u0430\u043a \u043b\u0438\u043d\u0442\u0435\u0440 \u0441\u043b\u0435\u0434\u0438\u0442 \u0437\u0430 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432? (CheckTypeSpecPosition)<\/h3>\n<p><strong>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e<\/strong><\/p>\n<pre><code class=\"go\">func NewPerson(name string) Person {   return Person{Name: name} }  type Person struct {   Name string }<\/code><\/pre>\n<p><strong>\u041e\u0448\u0438\u0431\u043a\u0430!<\/strong> \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u0440\u0430\u043d\u044c\u0448\u0435 \u0442\u0438\u043f\u0430. \u041b\u0438\u043d\u0442\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u044d\u0442\u043e \u043e\u0442\u043b\u043e\u0432\u0438\u0442\u044c \u0438 \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435.<\/p>\n<p><strong>\u041b\u043e\u0433\u0438\u043a\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438<\/strong><\/p>\n<pre><code>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0435 \u0441\u0442\u0435\u043a\u0430 (Stack) \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0423\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 (NewPerson). \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u043b\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0442\u0438\u043f \u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u043c Person. \u0415\u0441\u043b\u0438 \u0434\u0430 \u2014 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043e\u0448\u0438\u0431\u043a\u0443.<\/code><\/pre>\n<p><strong>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u043a\u043e\u0434\u0435<\/strong><\/p>\n<pre><code class=\"go\">func (v *validator) CheckTypeSpecPosition(typeSpec *ast.TypeSpec) {   if interfaceValue := v.Stack.Peek(); interfaceValue != nil {     if funcDecl, ok := interfaceValue.(*ast.FuncDecl); ok {       if isFunc(funcDecl) &amp;&amp; isFuncHasResults(funcDecl) {         result := funcDecl.Type.Results.List[0]         if isTypeNamedAsExpected(           unstar(v.Pass.TypesInfo.TypeOf(result.Type)),            typeSpec.Name.Name,         ) {           v.reportInvalidOrder(result.Pos(), result.Pos(),             \"the constructor must be positioned after the type is defined.\")           _ = v.Stack.Pop() \/\/ \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u0441\u0442\u0435\u043a\u0430         }       }     }   } }<\/code><\/pre>\n<p><strong>\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442?<\/strong><\/p>\n<ul>\n<li>\n<p><code>Stack.Peek()<\/code> \u0431\u0435\u0440\u0451\u0442 <strong>\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442<\/strong> (\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440);<\/p>\n<\/li>\n<li>\n<p><code>isFunc(funcDecl)<\/code> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u043e <strong>\u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0430 \u043d\u0435 \u043c\u0435\u0442\u043e\u0434<\/strong>;<\/p>\n<\/li>\n<li>\n<p><code>isFuncHasResults(funcDecl)<\/code> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e <strong>\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0447\u0442\u043e-\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442<\/strong>;<\/p>\n<\/li>\n<li>\n<p><code>isTypeNamedAsExpected()<\/code> \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 <strong>\u0438\u043c\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u043c<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0451 \u0441\u043e\u0432\u043f\u0430\u043b\u043e, <strong>\u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443<\/strong> \u0438 <strong>\u0443\u0434\u0430\u043b\u044f\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438\u0437 \u0441\u0442\u0435\u043a\u0430<\/strong>, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0435\u0433\u043e \u0434\u0432\u0430\u0436\u0434\u044b.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438<\/h2>\n<p>\u041c\u044b \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u0438 \u0433\u043e\u0442\u043e\u0432\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, <strong>\u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430\u0448 \u043b\u0438\u043d\u0442\u0435\u0440<\/strong>. \u041d\u043e \u043a\u0430\u043a \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043e\u0448\u0438\u0431\u043a\u0438?<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u043f\u0438\u0448\u0435\u043c <strong>\u043b\u0438\u043d\u0442\u0435\u0440<\/strong>, \u044f \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e <strong>\u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0441\u0440\u0430\u0437\u0443 \u0440\u044f\u0434\u043e\u043c \u0441 \u043a\u043e\u0434\u043e\u043c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438<\/strong>. \u042d\u0442\u043e \u0434\u0430\u0451\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432:<\/p>\n<ul>\n<li>\n<p>\u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u0432\u0438\u0434\u0438\u043c, \u0433\u0434\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438, \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u043d\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b;<\/p>\n<\/li>\n<li>\n<p><strong>\u0442\u0435\u0441\u0442\u044b \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/strong> \u2014 \u0432\u0441\u0451 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043f\u0440\u044f\u043c\u043e \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432<\/h3>\n<p>\u0422\u0435\u0441\u0442\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0435: <code>analyzers\/properorder\/analyzer_test.go<\/code><\/p>\n<pre><code class=\"go\">package properorder_test  import (   \"testing\"    \"gitlab.com\/common\/linter\/analyzers\/properorder\"   \"gitlab.com\/common\/linter\/internal\/tests\" )  func TestAll(t *testing.T) {   tests.AnalyzeCodeInTestdata(t, properorder.New()) }<\/code><\/pre>\n<ul>\n<li>\n<p><code>tests.AnalyzeCodeInTestdata(t, properorder.New())<\/code> \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043b\u0438\u043d\u0442\u0435\u0440 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043b\u0438\u043d\u0442\u0435\u0440 \u043d\u0435 \u043d\u0430\u0439\u0434\u0451\u0442 \u043e\u0448\u0438\u0431\u043a\u0443 \u0442\u0430\u043c, \u0433\u0434\u0435 \u0434\u043e\u043b\u0436\u0435\u043d, \u0438\u043b\u0438 \u0432\u044b\u0434\u0430\u0441\u0442 \u043e\u0448\u0438\u0431\u043a\u0443 \u043d\u0435 \u0442\u0430\u043c \u2014 \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0442\u0441\u044f.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0435\u0441\u0442 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 <strong>\u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438<\/strong>. \u0424\u0430\u0439\u043b\u044b \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 <code>analyzers\/properorder\/testdata\/src.go<\/code><\/p>\n<pre><code class=\"go\">type Car struct {   Model string }  func (c Car) Drive() { \/\/ want \"the method must be located below the constructor function.\"   println(\"Driving\") }  func NewCar(model string) Car {   return Car{Model: model} }<\/code><\/pre>\n<ul>\n<li>\n<p>\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 <code>\/\/ want \"...\"<\/code> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043b\u0438\u043d\u0442\u0435\u0440<strong> \u0414\u041e\u041b\u0416\u0415\u041d <\/strong>\u0437\u0434\u0435\u0441\u044c \u0432\u044b\u0434\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443;<\/p>\n<\/li>\n<li>\n<p>\u0435\u0441\u043b\u0438 \u043b\u0438\u043d\u0442\u0435\u0440 <strong>\u043d\u0435 \u0432\u044b\u0434\u0430\u0441\u0442 \u043e\u0448\u0438\u0431\u043a\u0443<\/strong>, <strong>\u0442\u0435\u0441\u0442 \u0443\u043f\u0430\u0434\u0451\u0442<\/strong>;<\/p>\n<\/li>\n<li>\n<p>\u0435\u0441\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 <strong>\u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u043c\u0435\u0441\u0442\u0435<\/strong>, <strong>\u0442\u0435\u0441\u0442 \u0442\u043e\u0436\u0435 \u0443\u043f\u0430\u0434\u0451\u0442<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432<\/h3>\n<h4>\u0415\u0441\u043b\u0438 \u0442\u0435\u0441\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0431\u0435\u0437 \u0442\u0435\u0433\u0430 \/\/ want<\/h4>\n<p>\u041b\u0438\u043d\u0442\u0435\u0440 \u043d\u0430\u0448\u0451\u043b \u043e\u0448\u0438\u0431\u043a\u0443, \u043d\u043e \u0442\u0435\u0441\u0442 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u043e\u0436\u0438\u0434\u0430\u043b\u0438 \u043b\u0438 \u043c\u044b \u0435\u0451, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d <strong>\u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0442\u0441\u044f<\/strong>:<\/p>\n<pre><code class=\"go\">=== RUN   TestAll linter\/analyzers\/properorder\/testdata\/src\/properorder.go:7:7  diagnostic the method must be located below the constructor function. --- FAIL: TestAll (0.02s)<\/code><\/pre>\n<h4>\u0415\u0441\u043b\u0438 \u0442\u0435\u0441\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0441 \u0442\u0435\u0433\u043e\u043c \/\/ want<\/h4>\n<p>\u041b\u0438\u043d\u0442\u0435\u0440 \u043d\u0430\u0448\u0451\u043b \u043e\u0448\u0438\u0431\u043a\u0443 <strong>\u0432 \u043d\u0443\u0436\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435<\/strong>, \u0442\u0435\u0441\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u0440\u043e\u0448\u0451\u043b:<\/p>\n<pre><code class=\"go\">=== RUN   TestAll --- PASS: TestAll (0.02s) PASS<\/code><\/pre>\n<h3>\u0412\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432<\/h3>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>AnalyzeCodeInTestdata(t testing.T, analyzer analysis.Analyzer)<\/code> <strong>\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043b\u0438\u043d\u0442\u0435\u0440<\/strong> \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445 \u0432 testdata\/src \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043b\u0438 \u043e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<h4>\u0420\u0430\u0437\u0431\u043e\u0440 \u043a\u043e\u0434\u0430<\/h4>\n<pre><code class=\"go\">func AnalyzeCodeInTestdata(t *testing.T, analyzer *analysis.Analyzer) {   wd, err := os.Getwd()   if err != nil {     panic(err)   }    var printer errsPrinter   analysistest.Run(&amp;printer, filepath.Join(wd, \"testdata\/src\"), analyzer, \".\/...\")   if printer.PrintedLines &gt; 0 {     t.Fail()   } }<\/code><\/pre>\n<ul>\n<li>\n<p><code>os.Getwd()<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 <strong>\u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e<\/strong>, \u0433\u0434\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u0441\u0442;<\/p>\n<\/li>\n<li>\n<p><code>analysistest.Run()<\/code> <strong>\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043b\u0438\u043d\u0442\u0435\u0440<\/strong> \u043d\u0430 \u0444\u0430\u0439\u043b\u0430\u0445 \u0432 testdata\/src;<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 <code>printer.PrintedLines &gt; 0<\/code> (\u0435\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438), <strong>\u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f<\/strong> (<code>t.Fail()<\/code>).<\/p>\n<\/li>\n<\/ul>\n<h4>\u041a\u0430\u043a \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f?<\/h4>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>errsPrinter.Errorf()<\/code> \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u043e\u0448\u0438\u0431\u043e\u043a \u043e\u0442 \u043b\u0438\u043d\u0442\u0435\u0440\u0430 \u0438 \u0438\u0445 \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c.<\/p>\n<pre><code class=\"go\">type errsPrinter struct {   PrintedLines int }  func (p *errsPrinter) Errorf(format string, args ...interface{}) {   fmt.Println(args...) \/\/ \u0412\u044b\u0432\u043e\u0434 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c   p.PrintedLines++     \/\/ \u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u043e\u0448\u0438\u0431\u043e\u043a }<\/code><\/pre>\n<ul>\n<li>\n<p><strong>\u0435\u0441\u043b\u0438 \u043b\u0438\u043d\u0442\u0435\u0440 \u043d\u0430\u0448\u0451\u043b \u043e\u0448\u0438\u0431\u043a\u0443<\/strong>, \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>Errorf()<\/code>;<\/p>\n<\/li>\n<li>\n<p><strong>\u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c (<\/strong><code>fmt.Println()<\/code><strong>)<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b <strong>\u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043e\u0441\u043d\u043e\u0432\u0443 \u043b\u0438\u043d\u0442\u0435\u0440\u0430 <\/strong><code>ProperOrder<\/code>. \u041c\u044b \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c \u043f\u0440\u043e\u0448\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b, \u0432\u043a\u043b\u044e\u0447\u0430\u044f:<\/p>\n<ul>\n<li>\n<p><strong>\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/strong> \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u043b\u0438\u043d\u0442\u0435\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p><strong>\u0440\u0430\u0437\u0431\u043e\u0440 AST \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0435\u043a\u0430<\/strong> \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p><strong>\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435?<\/h3>\n<p>\u0425\u043e\u0442\u044f \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043d\u0430\u0448 \u043b\u0438\u043d\u0442\u0435\u0440 \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u044b:<\/p>\n<ul>\n<li>\n<p><strong>\u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 <\/strong><code>Golangci-lint<\/code><strong> \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 merge\u2019\u0430 \u0432 \u043e\u0431\u0449\u0438\u0439 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439;<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043b\u0438\u043d\u0442\u0435\u0440 \u0432 <\/strong><code>CI\/CD<\/code><strong>.<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043a\u043e\u0434\u043e\u043c \u0438\u043b\u0438 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043b\u0438\u043d\u0442\u0435\u0440 \u043f\u043e\u0434 \u0441\u0432\u043e\u0438 \u043d\u0443\u0436\u0434\u044b \u2014 \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 GitHub: <a href=\"https:\/\/github.com\/akrovv\/properorder\">ProperOrder<\/a>.<\/p>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439 \u0438\u0437 \u041e\u0441\u0442\u0440\u043e\u0432\u043a\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c <a href=\"https:\/\/t.me\/ostrovok_tech\">Telegram-\u043a\u0430\u043d\u0430\u043b\u0435<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/908768\/\"> https:\/\/habr.com\/ru\/articles\/908768\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u0440\u0442\u0451\u043c \u0411\u043b\u043e\u0445\u0438\u043d, \u044f Go-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0439 \u041e\u0441\u0442\u0440\u043e\u0432\u043a\u0430. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043b\u0438\u043d\u0442\u0438\u043d\u0433\u0435 \u043a\u043e\u0434\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0431\u044b \u00ab\u0421\u0443\u043c\u0435\u0440\u043a\u0438\u00bb \u0431\u044b\u043b\u0438 \u043f\u0440\u043e \u043a\u043e\u0434, \u042d\u0434\u0432\u0430\u0440\u0434 \u2014 \u0431\u044b\u043b \u043b\u0438\u043d\u0442\u0435\u0440\u043e\u043c, \u0430 \u0411\u0435\u043b\u043b\u0430 \u2014 \u043b\u0435\u0433\u0430\u0441\u0438-\u043a\u043e\u0434\u043e\u043c, \u0438\u0445 \u0434\u0438\u0430\u043b\u043e\u0433 \u0437\u0432\u0443\u0447\u0430\u043b \u0431\u044b \u0442\u0430\u043a:<\/p>\n<blockquote>\n<p>\u2014 \u041b\u0438\u043d\u0442\u0435\u0440 \u0441\u043c\u043e\u0442\u0440\u0435\u043b \u043d\u0430 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0441 \u0431\u043e\u043b\u044c\u044e \u0438 \u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435\u043c.<br \/>\u2014 \u041a\u0430\u043a\u0430\u044f \u0433\u043b\u0443\u043f\u0430\u044f, \u0437\u0430\u0431\u044b\u0442\u0430\u044f \u0432\u0441\u0435\u043c\u0438 \u043a\u043e\u0434\u043e\u0432\u0430\u044f \u0431\u0430\u0437\u0430.<br \/>\u2014 \u041d\u0443, \u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0437\u044f\u043b\u0441\u044f \u0435\u0451 \u0447\u0438\u043d\u0438\u0442\u044c, \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0430\u0437\u043e\u0445\u0438\u0441\u0442.<\/p>\n<\/blockquote>\n<p>\u041b\u044e\u0431\u043e\u0439, \u043a\u0442\u043e \u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u0442\u0430\u0440\u043e\u043c \u043a\u043e\u0434\u0435 \u0431\u0435\u0437 \u0441\u0442\u0430\u0442\u0438\u043a\u0438, \u0437\u043d\u0430\u0435\u0442: \u0447\u0435\u043c \u0433\u043b\u0443\u0431\u0436\u0435 \u043a\u043e\u043f\u0430\u0435\u0448\u044c, \u0442\u0435\u043c \u0441\u0442\u0440\u0430\u0448\u043d\u0435\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f. \u0412 <a href=\"https:\/\/habr.com\/ru\/companies\/ostrovok\/articles\/839514\/\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043b\u0438\u043d\u0442\u0435\u0440\u044b \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0440\u0430 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u2014 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043b\u0438\u043d\u0442\u0435\u0440 \u0438 \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0435\u0433\u043e \u0432 <code>golangci-lint<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0441\u0430\u043c \u0432\u044b\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430.<\/p>\n<h3>Disclaimer<\/h3>\n<p>\u041b\u0438\u043d\u0442\u0435\u0440 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0431\u044a\u0451\u043c\u043d\u044b\u0439 (200+ \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430), \u0438 \u0435\u0441\u043b\u0438 \u0431\u044b \u044f \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0437\u0430\u043f\u0438\u0445\u043d\u0443\u0442\u044c \u0432\u0441\u0451 \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0430\u0442\u044c\u044e, \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0436\u0435\u0441\u0442\u043e\u043a\u043e \u2014 \u0438 \u0434\u043b\u044f \u0432\u0430\u0441, \u0438 \u0434\u043b\u044f \u043c\u043e\u0435\u0439 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 <strong>\u0432 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/strong> \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438.\u00a0<\/p>\n<p>\u041f\u0440\u0438\u0441\u0442\u0451\u0433\u0438\u0432\u0430\u0439\u0442\u0435\u0441\u044c, \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e!<\/p>\n<h2>\u041a\u0430\u043a \u0440\u043e\u0434\u0438\u043b\u0441\u044f ProperOrder, \u0438\u043b\u0438 \u00ab\u0440\u0430\u0437\u043e\u0440\u0432\u0430\u0442\u044c \u0441\u0435\u043c\u0435\u0439\u043d\u044b\u0435 \u0443\u0437\u044b\u00bb<\/h2>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u043f\u0438\u0441\u0430\u0442\u044c \u043b\u0438\u043d\u0442\u0435\u0440, \u044f \u0434\u043e\u043b\u0433\u043e \u043b\u043e\u043c\u0430\u043b \u0433\u043e\u043b\u043e\u0432\u0443: \u043a\u0430\u043a\u043e\u0439 \u043a\u0435\u0439\u0441 \u0432\u0437\u044f\u0442\u044c? \u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c, \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 \u043d\u0430\u0448 \u043d\u043e\u0432\u044b\u0439 \u043b\u0438\u043d\u0442\u0435\u0440 \u2014 <code>ProperOrder<\/code>.<\/p>\n<h3>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 ProperOrder?<\/h3>\n<p>\u041e\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e \u043a\u043e\u0434 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0432 \u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435:<\/p>\n<ul>\n<li>\n<p>\u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0442\u043e\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 (\u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c);<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0442\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b.<\/p>\n<\/li>\n<\/ul>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043a\u043e\u0434\u0430 \u0438 \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439. \u042d\u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0432\u043e\u0441\u043f\u0440\u0438\u044f\u0442\u0438\u0435 \u0438 \u043a\u0430\u043a <code>ProperOrder<\/code> \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0435\u0433\u043e \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0442\u044c.<\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440 1 (\u043d\u0435\u0443\u0434\u0430\u0447\u043d\u044b\u0439)<\/strong>:<\/p>\n<pre><code class=\"go\">type Man struct {...}  type Woman struct {...}  func (m Man) GetName() string {...}  func (w Woman) GetName() string {...}<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u0435\u0442\u043e\u0434 <code>GetName<\/code> \u0434\u043b\u044f <code>Man<\/code> \u0440\u0430\u0437\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b <code>Woman<\/code>. \u041a\u043e\u0433\u0434\u0430 \u043a\u043e\u0434 \u0440\u0430\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u0441\u043d\u0438\u0436\u0430\u044e\u0442 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c.<\/p>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440 2 (\u0443\u0434\u0430\u0447\u043d\u044b\u0439)<\/strong>:<\/p>\n<pre><code class=\"go\">type Man struct {...}  func (m Man) GetName() string {...}  type Woman struct {...}  func (w Woman) GetName() string {...}<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0451 \u043b\u043e\u0433\u0438\u0447\u043d\u043e: \u043e\u0431\u044a\u044f\u0432\u0438\u043b\u0438 <code>Man<\/code>, \u0437\u0430\u0442\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434.<\/p>\n<h4>\u041a\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0440\u0443\u0448\u0430\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a?<\/h4>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f <strong>\u043d\u0435 \u0441\u0442\u0440\u043e\u0433\u043e \u0434\u0440\u0443\u0433 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u043c<\/strong>, \u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"go\">type Man struct {...}  type Health struct {...}  func NewMan(h Health) Man {..}  type Woman struct {...}  func (m Man) FindLove(w []Woman) (Woman) {...}<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043a\u043e\u0434\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 <code>Health<\/code> \u0438\u0434\u0451\u0442 <strong>\u0434\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 <\/strong><code>NewMan<\/code>, \u0445\u043e\u0442\u044f \u0441\u0430\u043c <code>Man<\/code> \u0443\u0436\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d. \u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e <code>Health<\/code> <strong>\u043d\u0443\u0436\u0435\u043d \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430<\/strong>.<\/p>\n<p>\u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0441 <code>FindLove<\/code>: \u0437\u0434\u0435\u0441\u044c \u043c\u0430\u0441\u0441\u0438\u0432 <code>[]Woman<\/code> \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043c\u0435\u0442\u043e\u0434\u0430 <code>Man<\/code>, \u0430 \u0441\u0430\u043c \u043c\u0435\u0442\u043e\u0434 <strong>\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <\/strong><code>Woman<\/code>. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043b\u0438\u043d\u0442\u0435\u0440 <strong>\u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0443\u0433\u0430\u0442\u044c\u0441\u044f<\/strong>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043b\u043e\u0433\u0438\u0447\u0435\u043d: <strong>\u0422\u0438\u043f\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0438\u043b\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445, \u043c\u043e\u0433\u0443\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0440\u0430\u043d\u044c\u0448\u0435.<\/strong><\/p>\n<h2>\u0410 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0434\u043b\u044f \u043b\u0438\u043d\u0442\u0435\u0440\u0430?<\/h2>\n<p>\u041e\u0434\u043d\u0430 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u0443\u0442\u0438 \u2014 \u044d\u0442\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0447\u0451\u0442\u043a\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0446\u0430 \u0438\u043b\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043b\u0438\u043d\u0442\u0435\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c. \u0418\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0443\u0436\u0438\u0445 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432 \u0432 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043d\u0435 \u0434\u0430\u0432\u0430\u043b\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.<\/p>\n<p>\u041f\u043e\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u0444\u0430\u043a\u0442: \u0434\u0430\u0436\u0435 \u043b\u0438\u043d\u0442\u0435\u0440\u044b, \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u0438 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u043d\u0435\u0440\u0435\u0434\u043a\u043e \u0441\u0442\u0440\u0430\u0434\u0430\u044e\u0442 \u043e\u0442 \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0438 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b. \u042d\u0442\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u043c \u0431\u0430\u0440\u044c\u0435\u0440\u043e\u043c \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u0433\u043b\u0443\u0431\u0436\u0435 \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0437\u0431\u043e\u0440 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u044b. \u041e\u0442\u0441\u044e\u0434\u0430 \u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043b\u0438\u043d\u0442\u0435\u0440\u043e\u0432, \u0443\u0434\u0435\u043b\u044f\u044f \u043e\u0441\u043e\u0431\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438, \u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 <code>user-friendly<\/code> \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041a\u0430\u043a \u0438\u0442\u043e\u0433, \u044f \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u0442\u0430\u043a\u043e\u043c\u0443 \u0432\u0438\u0434\u0443:<\/p>\n<pre><code>\u251c\u2500\u2500 analyzers \u2502   \u2514\u2500\u2500 custom_linter \u2502       \u251c\u2500\u2500 analyzer.go \u2502       \u251c\u2500\u2500 analyzer_test.go \u2502       \u2514\u2500\u2500 testdata \u2502           \u2514\u2500\u2500 src \u2502               \u2514\u2500\u2500 src.go \u251c\u2500\u2500 cmd \u2502   \u2514\u2500\u2500 custom_linter \u2502       \u2514\u2500\u2500 main.go \u2502\u2500\u2500 internal \u2502   \u2514\u2500\u2500 tests \u2502       \u2514\u2500\u2500 tests.go \u2514\u2500\u2500 plugin     \u2514\u2500\u2500 main.go<\/code><\/pre>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435:<\/p>\n<pre><code>analyzers\/        \u2014 \u0437\u0434\u0435\u0441\u044c \u0436\u0438\u0432\u0451\u0442 \u0432\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043b\u0438\u043d\u0442\u0435\u0440\u0430   \u251c\u2500\u2500 analyzer.go        \u2014 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043a\u043e\u0434\u0430   \u251c\u2500\u2500 analyzer_test.go   \u2014 \u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u043b\u0438\u043d\u0442\u0435\u0440\u0430   \u2514\u2500\u2500 testdata\/          \u2014 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043b\u0438\u043d\u0442\u0435\u0440                              (\u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438 \u0442\u043e,                                                \u0447\u0442\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0443\u0433\u0430\u0442\u044c) cmd\/              \u2014 \u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430   \u2514\u2500\u2500 main.go           \u2014 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043b\u0438\u043d\u0442\u0435\u0440 (\u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u043e\u0433\u043d\u0430\u0442\u044c \u0435\u0433\u043e                                            \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0442 golangci-lint) internal\/         \u2014 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0437\u0430\u0434\u0430\u0447   \u2514\u2500\u2500 tests.go          \u2014 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 plugin\/           \u2014 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043b\u0438\u043d\u0442\u0435\u0440\u0430 \u0432 golangci-lint   \u2514\u2500\u2500 main.go<\/code><\/pre>\n<h3>\u0417\u0430\u043f\u0443\u0441\u043a \u043b\u0438\u043d\u0442\u0435\u0440\u0430<\/h3>\n<pre><code class=\"go\">package main  import (   \"golang.org\/x\/tools\/go\/analysis\/singlechecker\"   \"gitlab.com\/common\/linter\/analyzers\/properorder\" )  func main() {   singlechecker.Main(properorder.New()) }<\/code><\/pre>\n<p><code>singlechecker.Main(properorder.New())<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0434\u043b\u044f \u043b\u0438\u043d\u0442\u0435\u0440\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c <strong>\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u043d\u0442\u0435\u0440\u043e\u0432<\/strong>, \u0432\u043c\u0435\u0441\u0442\u043e <code>singlechecker<\/code> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>multichecker.Main()<\/code>.<\/p>\n<h2>\u041b\u0438\u043d\u0442\u0435\u0440, \u0438\u043b\u0438 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u041f\u0440\u043e\u043c\u0435\u0442\u0435\u0439<\/h2>\n<p>\u041a\u043e\u0434 \u0440\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0438\u0434\u0435\u0438. \u041a\u0430\u043a\u0430\u044f \u0443 \u043d\u0430\u0441 \u0438\u0434\u0435\u044f? <strong>\u041f\u043e\u0440\u044f\u0434\u043e\u043a<\/strong>.<br \/>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 <code>ProperOrder<\/code>, \u2014 <strong>\u043a\u0430\u043a \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0437\u0430 \u0447\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442?<\/strong><\/p>\n<p>\u041a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <code>GetName<\/code> \u0434\u043b\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b <code>Man<\/code>, \u0433\u0434\u0435-\u0442\u043e <strong>\u0432\u044b\u0448\u0435<\/strong> \u0443\u0436\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 \u044d\u0442\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430? \u0418\u043b\u0438 \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c <code>NewPerson<\/code> \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0434\u0451\u0442 <code>type Person struct {}<\/code>?<\/p>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043f\u0440\u043e\u0441\u0442: \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c<strong> <\/strong><code>\u0441\u0442\u0435\u043a<\/code>. \u041d\u043e \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2013 \u0441\u0442\u0435\u043a \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0449\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b.<\/p>\n<h3>\u0421\u0442\u0435\u043a \u2014 \u043a\u043b\u044e\u0447 \u043a \u043f\u043e\u0440\u044f\u0434\u043a\u0443<\/h3>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043b\u0438\u043d\u0442\u0435\u0440 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0444\u0430\u0439\u043b, \u043e\u043d \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0435 <strong>\u0432\u0430\u0436\u043d\u044b\u0435 \u0443\u0437\u043b\u044b<\/strong> \u0432 \u0441\u0442\u0435\u043a \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0435\u043d \u043b\u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a.<\/p>\n<p><strong>\u0427\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u0441\u0442\u0435\u043a\u0435?<\/strong><\/p>\n<ul>\n<li>\n<p><code>ast.FuncDecl<\/code> \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b (<code>func Foo()<\/code> \u0438\u043b\u0438 <code>func (r *Receiver) Foo()<\/code>);<\/p>\n<\/li>\n<li>\n<p><code>ast.TypeSpec<\/code> \u2014 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 (<code>type Man struct{}<\/code>).<\/p>\n<\/li>\n<\/ul>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 1 \u0438 \u043f\u0440\u043e\u0439\u0434\u0451\u043c\u0441\u044f \u043f\u043e \u043a\u043e\u0434\u0443 \u0441\u0432\u0435\u0440\u0445\u0443-\u0432\u043d\u0438\u0437, \u043f\u043e\u043f\u0443\u0442\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044f \u0432 \u0441\u0442\u0435\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0427\u0442\u043e \u0436\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c? \u041a\u0440\u0430\u0441\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u0442\u0435\u043a\u0430 (\u043c\u0435\u0442\u043e\u0434 <code>Man<\/code>) \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0438\u0436\u0435\u043b\u0435\u0436\u0430\u0449\u0435\u043c\u0443 (\u0442\u0438\u043f <code>Woman<\/code>). <\/p>\n<h2>\u041a\u0430\u043a ProperOrder \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0434?<\/h2>\n<p>\u0412\u0435\u0441\u044c \u0430\u043d\u0430\u043b\u0438\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>run()<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430. <code>run()<\/code> \u2014 \u044d\u0442\u043e <strong>\u0441\u0435\u0440\u0434\u0446\u0435 \u043b\u0438\u043d\u0442\u0435\u0440\u0430<\/strong>. \u0418\u043c\u0435\u043d\u043d\u043e \u043e\u043d\u0430 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 AST, \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0438 \u0432\u044b\u0437\u043e\u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a.<\/p>\n<p>\u041d\u043e \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>run()<\/code>, \u043d\u0443\u0436\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043b\u0438\u043d\u0442\u0435\u0440:<\/p>\n<pre><code class=\"go\">package properoder  import \"golang.org\/x\/tools\/go\/analysis\"  func New() *analysis.Analyzer {   return &amp;analysis.Analyzer{     Name:     \"properorder\",     Doc:      \"short documentation about linter\",     Run:      run,     URL:      \"https:\/\/documentation.com\",     Requires: []*analysis.Analyzer{inspect.Analyzer},   } }<\/code><\/pre>\n<p>\u0423\u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u043d\u0438\u043c:<\/p>\n<ul>\n<li>\n<p><code>Name<\/code> \u2013 \u0438\u043c\u044f \u043b\u0438\u043d\u0442\u0435\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p><code>Doc<\/code> \u2013 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043b\u0438\u043d\u0442\u0435\u0440\u0430 (\u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u0438 \u0442.\u0434.). \u0414\u043b\u0438\u043d\u043d\u044b\u043c \u0431\u044b\u0442\u044c \u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f.<\/p>\n<\/li>\n<li>\n<p><code>Run<\/code> \u2013 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043b\u0438\u043d\u0442\u0435\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p><code>URL<\/code> \u2013 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043b\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u043e\u043b\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e.<\/p>\n<\/li>\n<li>\n<p><code>Requires<\/code> \u2013 \u043d\u0435\u043a\u0430\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f: <code>golangci-lint<\/code> \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 <code>inspect.Analyzer<\/code> \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u0432 (\u043d\u0430\u0448\u0438\u0445 \u043b\u0438\u043d\u0442\u0435\u0440\u043e\u0432). \u0422\u043e \u0435\u0441\u0442\u044c, \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043b\u0438\u043d\u0442\u0435\u0440\u0430 \u0437\u0430\u043d\u043e\u0432\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c AST-\u0434\u0435\u0440\u0435\u0432\u043e.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 run()?<\/h3>\n<pre><code class=\"go\">func run(pass *analysis.Pass) (any, error) {   var lastFile *token.File   v := validator{     Pass: pass,     Stack: stack.New(),   }<\/code><\/pre>\n<p><code>pass *analysis.Pass<\/code> \u2014 \u043e\u0431\u044a\u0435\u043a\u0442, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 <strong>\u0432\u0441\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u043e\u0434\u0435<\/strong> (\u0444\u0430\u0439\u043b\u044b, \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0443\u0437\u043b\u043e\u0432 \u0438 \u0442. \u0434.).<\/p>\n<p><code>validator<\/code> \u2014 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432 \u043b\u0438\u043d\u0442\u0435\u0440\u0435. \u0412 \u043d\u0435\u0439 \u0435\u0441\u0442\u044c:<\/p>\n<ul>\n<li>\n<p><code>Pass<\/code> \u2014 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <code>analysis.Pass<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>Stack<\/code> \u2014 <strong>\u0441\u0442\u0435\u043a \u0443\u0437\u043b\u043e\u0432<\/strong> AST, \u0433\u0434\u0435 \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c, \u043a\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0443\u0436\u0435 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u043b\u0438\u0441\u044c.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041a\u0430\u043a\u0438\u0435 \u0443\u0437\u043b\u044b \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442?<\/h3>\n<pre><code class=\"go\">nodeTypes := []ast.Node{   (*ast.FuncDecl)(nil), \/\/ func Foo() or func (r *Receiver) Foo()   (*ast.TypeSpec)(nil), \/\/ type smt (e.g. struct, int, array etc) }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b <strong>\u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u043c AST<\/strong> \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u043c, \u0447\u0442\u043e \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 <strong>\u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/strong>.<\/p>\n<h3>\u041a\u0430\u043a run() \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0434?<\/h3>\n<p>\u041f\u0440\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>enterNode()<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0435\u0448\u0430\u0435\u0442, \u0447\u0442\u043e \u0441 \u043d\u0438\u043c \u0434\u0435\u043b\u0430\u0442\u044c:<\/p>\n<pre><code class=\"go\">enterNode := func(n ast.Node) bool {   currentFile := pass.Fset.File(n.Pos())    if lastFile == nil || currentFile != lastFile {     v.flushStack() \/\/ \u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u0441\u0442\u0435\u043a\u0430 \u043f\u0440\u0438 \u0441\u043c\u0435\u043d\u0435 \u0444\u0430\u0439\u043b\u0430   }   lastFile = currentFile<\/code><\/pre>\n<p><strong>\u0415\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0448\u043b\u0438 \u0432 \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b<\/strong> \u2014 <strong>\u043e\u0447\u0438\u0449\u0430\u0435\u043c \u0441\u0442\u0435\u043a<\/strong>. \u042d\u0442\u043e \u0432\u0430\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043b\u0438\u043d\u0442\u0435\u0440 \u043d\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 <strong>\u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432<\/strong>.<\/p>\n<h3>\u041a\u0430\u043a enterNode() \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0443\u0437\u043b\u044b?<\/h3>\n<pre><code class=\"go\">switch node := n.(type) { case *ast.TypeSpec:   v.CheckTypeSpecPosition(node) \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0433\u0434\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u0442\u0438\u043f   v.Stack.Push(node)             \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u0432 \u0441\u0442\u0435\u043a  case *ast.FuncDecl:   v.TraverseStack(node)         \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043c\u0435\u0442\u043e\u0434\u043e\u0432   v.Stack.Push(node)             \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u0432 \u0441\u0442\u0435\u043a }<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 <strong>\u044d\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 (<\/strong><code>TypeSpec<\/code><strong>)<\/strong> \u2013 <strong>\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0451 \u043f\u043e\u0440\u044f\u0434\u043e\u043a<\/strong> \u0438 \u043a\u043b\u0430\u0434\u0451\u043c \u0432 \u0441\u0442\u0435\u043a.<\/p>\n<p>\u0415\u0441\u043b\u0438 <strong>\u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 (<\/strong><code>FuncDecl<\/code><strong>)<\/strong> \u2013 <strong>\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0441\u0442\u043e\u0438\u0442 \u043b\u0438 \u043e\u043d\u0430 \u043d\u0430 \u0441\u0432\u043e\u0451\u043c \u043c\u0435\u0441\u0442\u0435<\/strong>, \u0437\u0430\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0441\u0442\u0435\u043a.<\/p>\n<h3>\u041a\u0430\u043a \u043b\u0438\u043d\u0442\u0435\u0440 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043f\u043e AST?<\/h3>\n<pre><code class=\"go\">inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) inspect.WithStack(nodeTypes, func(n ast.Node, push bool, stack []ast.Node) (proceed bool) {   if push {     return enterNode(n) \/\/ \u0410\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0443\u0437\u0435\u043b   }   return true })<\/code><\/pre>\n<p><code>WithStack<\/code> <strong>\u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043f\u043e AST<\/strong>, \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 <strong>\u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u044b\u0435 \u0443\u0437\u043b\u044b<\/strong> (<code>TypeSpec<\/code>, <code>FuncDecl<\/code>) \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>enterNode()<\/code> \u0434\u043b\u044f \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<p>push bool \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442:<\/p>\n<ul>\n<li>\n<p><code>true<\/code> \u2013 \u043c\u044b <strong>\u0432\u043e\u0448\u043b\u0438 \u0432 \u0443\u0437\u0435\u043b<\/strong>, \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e (<code>enterNode(n)<\/code>);<\/p>\n<\/li>\n<li>\n<p><code>false<\/code> \u2013 \u043c\u044b <strong>\u0432\u044b\u0448\u043b\u0438 \u0438\u0437 \u0443\u0437\u043b\u0430<\/strong>, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u043e\u0431\u0445\u043e\u0434.<\/p>\n<\/li>\n<\/ul>\n<p><code>Proceed = true<\/code>, \u043c\u044b \u0441\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u0441\u044f \u0433\u043b\u0443\u0431\u0436\u0435 \u0432 ast, <code>= false<\/code>, \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u043c \u043e\u0431\u0445\u043e\u0434 \u0443\u0437\u043b\u0430.<\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"go\">func run(pass *analysis.Pass) (any, error) {   var lastFile *token.File   v := validator{     Pass: pass,     Stack: stack.New(),   }    nodeTypes := []ast.Node{     (*ast.FuncDecl)(nil), \/\/ func Foo() or func (r *Receiver) Foo()     (*ast.TypeSpec)(nil), \/\/ type smt (e.g. struct, int, array etc)   }   enterNode := func(n ast.Node) bool {     currentFile := pass.Fset.File(n.Pos())     if lastFile == nil || currentFile != lastFile {       v.flushStack()     }     lastFile = currentFile      switch node := n.(type) {     case *ast.TypeSpec:       v.CheckTypeSpecPosition(node)       v.Stack.Push(node)     case *ast.FuncDecl:       v.TraverseStack(node)    <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-459856","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/459856","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=459856"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/459856\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=459856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=459856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=459856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}