{"id":338640,"date":"2022-09-22T15:00:55","date_gmt":"2022-09-22T15:00:55","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=338640"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=338640","title":{"rendered":"<span>UseStdLibVars: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/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<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/384\/be0\/398\/384be0398218067d5c2eeddf1a03a65e.png\" width=\"1920\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/384\/be0\/398\/384be0398218067d5c2eeddf1a03a65e.png\"\/><figcaption><\/figcaption><\/figure>\n<p>Go-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0447\u0430\u0441\u0442\u043e \u043f\u0438\u0448\u0443\u0442 \u0441\u0432\u043e\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u043b\u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u0430\u00a0\u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0438\u0445\u00a0\u0432\u00a0\u043a\u043e\u0434\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a\u00a0\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0448 Go-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0421\u0430\u0448\u0430 \u041c\u0435\u043b\u0435\u043d\u0442\u044c\u0435\u0432 \u0441\u043e\u0437\u0434\u0430\u043b \u043b\u0438\u043d\u0442\u0435\u0440 usestdlibvars, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u043c\u043e\u0436\u043d\u043e\u00a0\u043b\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u043b\u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0438\u0437\u00a0\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435.<\/p>\n<div class=\"embed_link\">\n<div class=\"embed__thumb\" style=\"background-image: url(&quot;https:\/\/repository-images.githubusercontent.com\/517569545\/a1717bea-750d-4ef8-a6e3-24ad5a979d75&quot;);\"><\/div>\n<div class=\"embed__caption\">\n<div class=\"embed__caption-title\"><span>GitHub &#8212; sashamelentyev\/usestdlibvars: A linter that detect the possibility to use variables\/constants from the Go standard library.<\/span><\/div>\n<p><a href=\"https:\/\/github.com\/sashamelentyev\/usestdlibvars\" target=\"_blank\" rel=\"noopener noreferrer nofollow\" class=\"embed__caption-link\">github.com<\/a><\/div>\n<\/div>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u00a0\u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0435 \u0437\u0430\u043f\u0440\u043e\u0441. \u041e\u043d\u00a0\u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u0435\u0442\u043e\u0434, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, getpost, \u0432\u00a0\u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043d\u043e\u0433\u0438\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0442\u0430\u043a \u0438\u00a0\u043f\u0438\u0448\u0443\u0442\u00a0\u2014 get. \u041d\u043e\u00a0\u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u00a0\u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 \u0438\u0437\u00a0\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0412\u0430\u043c \u043d\u0435\u00a0\u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0439 \u043a\u043e\u0434, \u043b\u0438\u043d\u0442\u0435\u0440 \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u0432\u0430\u0448\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>\u041a\u00a0\u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0432\u043c\u0435\u0441\u0442\u043e <code>http.NewRequest(\"GET\", \"\", nil)<\/code> \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>http.NewRequest(http.MethodGet, \"\", nil)<\/code>\u00a0\u2014 \u043b\u0438\u043d\u0442\u0435\u0440 \u044d\u0442\u043e \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u0438\u0442.<\/p>\n<p>\u0412\u0430\u0436\u043d\u043e\u00a0\u0442\u043e, \u0447\u0442\u043e \u0432\u00a0\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e, \u043d\u043e\u00a0\u043e\u043d\u0438 \u043d\u0435\u00a0\u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442. \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443, \u0432\u00a0\u043d\u0430\u0448 \u043b\u0438\u043d\u0442\u0435\u0440 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0435 \u043e\u043f\u0446\u0438\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441\u00a0\u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 http), \u0447\u0442\u043e\u0431\u044b \u043d\u0435\u00a0\u0431\u044b\u043b\u043e \u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439.<\/p>\n<p>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043b\u0438\u043d\u0442\u0435\u0440\u0430, UseStdLibVars, \u043f\u043e\u00a0\u0441\u0443\u0442\u0438, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0437\u044b\u0432\u043e\u043c \u043a\u00a0\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044e \u00ab\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u00bb. \u041b\u0438\u043d\u0442\u0435\u0440 \u0443\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u0432\u00a0golangci-lint.<\/p>\n<h2>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h2>\n<pre><code>go install github.com\/sashamelentyev\/usestdlibvars@latest<\/code><\/pre>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<pre><code>$ usestdlibvars -h usestdlibvars: A linter that detect the possibility to use variables\/constants from the Go standard library.  Usage: usestdlibvars [-flag] [package]   Flags:   -V    print version and exit   -all         no effect (deprecated)   -c int         display offending line with this many lines of context (default -1)   -constant-kind         suggest the use of constant.Kind.String()   -cpuprofile string         write CPU profile to this file   -crypto-hash         suggest the use of crypto.Hash.String()   -debug string         debug flags, any subset of \"fpstv\"   -fix         apply all suggested fixes   -flags         print analyzer flags in JSON   -http-method         suggest the use of http.MethodXX (default true)   -http-status-code         suggest the use of http.StatusXX (default true)   -json         emit JSON output   -memprofile string         write memory profile to this file   -os-dev-null         suggest the use of os.DevNull   -rpc-default-path         suggest the use of rpc.DefaultXXPath   -source         no effect (deprecated)   -sql-isolation-level         suggest the use of sql.LevelXX.String()   -tags string         no effect (deprecated)   -test         indicates whether test files should be analyzed, too (default true)   -time-layout         suggest the use of time.Layout   -time-month         suggest the use of time.Month.String()   -time-weekday         suggest the use of time.Weekday.String()   -tls-signature-scheme         suggest the use of tls.SignatureScheme.String()   -trace string         write trace log to this file   -v    no effect (deprecated)<\/code><\/pre>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440\u044b<\/h2>\n<pre><code>package response  import ( \"bytes\" \"encoding\/json\" \"net\/http\" )  \/\/ JSON marshals v to JSON, automatically escaping HTML, \/\/ setting the Content-Type header as \"application\/json; charset=utf-8\", \/\/ sends an HTTP response header with the provided statusCode and \/\/ writes the marshaled v as bytes to the connection as part of an HTTP reply. func JSON(w http.ResponseWriter, statusCode int, v any) { var buf bytes.Buffer enc := json.NewEncoder(&amp;buf) enc.SetEscapeHTML(true) if err := enc.Encode(v); err != nil { http.Error(w, err.Error(), 500) return } w.Header().Set(\"Content-Type\", \"application\/json; charset=utf-8\") w.WriteHeader(statusCode) if _, err := w.Write(buf.Bytes()); err != nil { http.Error(w, err.Error(), 500) return } }<\/code><\/pre>\n<pre><code>usestdlibvars .\/...<\/code><\/pre>\n<pre><code>response.go:18:30: \"500\" can be replaced by http.StatusInternalServerError response.go:24:30: \"500\" can be replaced by http.StatusInternalServerError<\/code><\/pre>\n<h2>\u041f\u043b\u0430\u043d\u044b \u043d\u0430\u00a0\u0431\u0443\u0434\u0443\u0449\u0435\u0435<\/h2>\n<p>\u041c\u044b\u00a0\u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432\u00a0\u044f\u0437\u044b\u043a\u0435. \u0415\u0441\u043b\u0438 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u00a0\u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043c\u044b\u00a0\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043b\u0438\u043d\u0442\u0435\u0440\u0430. \u0412\u044b\u00a0\u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u0432\u043a\u043b\u0430\u0434 \u0438\u00a0\u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0442\u044c \u043d\u0430\u043c \u043f\u0443\u043b-\u0440\u0435\u043a\u0432\u0435\u0441\u0442\u044b.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/company\/evrone\/blog\/689606\/\"> https:\/\/habr.com\/ru\/company\/evrone\/blog\/689606\/<\/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<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>Go-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0447\u0430\u0441\u0442\u043e \u043f\u0438\u0448\u0443\u0442 \u0441\u0432\u043e\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u043b\u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u0430\u00a0\u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0438\u0445\u00a0\u0432\u00a0\u043a\u043e\u0434\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a\u00a0\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0448 Go-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0421\u0430\u0448\u0430 \u041c\u0435\u043b\u0435\u043d\u0442\u044c\u0435\u0432 \u0441\u043e\u0437\u0434\u0430\u043b \u043b\u0438\u043d\u0442\u0435\u0440 usestdlibvars, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442, \u043c\u043e\u0436\u043d\u043e\u00a0\u043b\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u043b\u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0438\u0437\u00a0\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435.<\/p>\n<div class=\"embed_link\">\n<div class=\"embed__thumb\" style=\"background-image: url(&quot;https:\/\/repository-images.githubusercontent.com\/517569545\/a1717bea-750d-4ef8-a6e3-24ad5a979d75&quot;);\"><\/div>\n<div class=\"embed__caption\">\n<div class=\"embed__caption-title\"><span>GitHub &#8212; sashamelentyev\/usestdlibvars: A linter that detect the possibility to use variables\/constants from the Go standard library.<\/span><\/div>\n<p><a href=\"https:\/\/github.com\/sashamelentyev\/usestdlibvars\" target=\"_blank\" rel=\"noopener noreferrer nofollow\" class=\"embed__caption-link\">github.com<\/a><\/div>\n<\/div>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u00a0\u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0435 \u0437\u0430\u043f\u0440\u043e\u0441. \u041e\u043d\u00a0\u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u0435\u0442\u043e\u0434, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, getpost, \u0432\u00a0\u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043d\u043e\u0433\u0438\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0442\u0430\u043a \u0438\u00a0\u043f\u0438\u0448\u0443\u0442\u00a0\u2014 get. \u041d\u043e\u00a0\u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u00a0\u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 \u0438\u0437\u00a0\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0412\u0430\u043c \u043d\u0435\u00a0\u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0439 \u043a\u043e\u0434, \u043b\u0438\u043d\u0442\u0435\u0440 \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u0432\u0430\u0448\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>\u041a\u00a0\u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0432\u043c\u0435\u0441\u0442\u043e <code>http.NewRequest(\"GET\", \"\", nil)<\/code> \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>http.NewRequest(http.MethodGet, \"\", nil)<\/code>\u00a0\u2014 \u043b\u0438\u043d\u0442\u0435\u0440 \u044d\u0442\u043e \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u0438\u0442.<\/p>\n<p>\u0412\u0430\u0436\u043d\u043e\u00a0\u0442\u043e, \u0447\u0442\u043e \u0432\u00a0\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e, \u043d\u043e\u00a0\u043e\u043d\u0438 \u043d\u0435\u00a0\u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442. \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443, \u0432\u00a0\u043d\u0430\u0448 \u043b\u0438\u043d\u0442\u0435\u0440 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0435 \u043e\u043f\u0446\u0438\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441\u00a0\u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 http), \u0447\u0442\u043e\u0431\u044b \u043d\u0435\u00a0\u0431\u044b\u043b\u043e \u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439.<\/p>\n<p>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043b\u0438\u043d\u0442\u0435\u0440\u0430, UseStdLibVars, \u043f\u043e\u00a0\u0441\u0443\u0442\u0438, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0437\u044b\u0432\u043e\u043c \u043a\u00a0\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044e \u00ab\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u00bb. \u041b\u0438\u043d\u0442\u0435\u0440 \u0443\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u0432\u00a0golangci-lint.<\/p>\n<h2>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h2>\n<pre><code>go install github.com\/sashamelentyev\/usestdlibvars@latest<\/code><\/pre>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<pre><code>$ usestdlibvars -h usestdlibvars: A linter that detect the possibility to use variables\/constants from the Go standard library.  Usage: usestdlibvars [-flag] [package]   Flags:   -V    print version and exit   -all         no effect (deprecated)   -c int         display offending line with this many lines of context (default -1)   -constant-kind         suggest the use of constant.Kind.String()   -cpuprofile string         write CPU profile to this file   -crypto-hash         suggest the use of crypto.Hash.String()   -debug string         debug flags, any subset of \"fpstv\"   -fix         apply all suggested fixes   -flags         print analyzer flags in JSON   -http-method         suggest the use of http.MethodXX (default true)   -http-status-code         suggest the use of http.StatusXX (default true)   -json         emit JSON output   -memprofile string         write memory profile to this file   -os-dev-null         suggest the use of os.DevNull   -rpc-default-path         suggest the use of rpc.DefaultXXPath   -source         no effect (deprecated)   -sql-isolation-level         suggest the use of sql.LevelXX.String()   -tags string         no effect (deprecated)   -test         indicates whether test files should be analyzed, too (default true)   -time-layout         suggest the use of time.Layout   -time-month         suggest the use of time.Month.String()   -time-weekday         suggest the use of time.Weekday.String()   -tls-signature-scheme         suggest the use of tls.SignatureScheme.String()   -trace string         write trace log to this file   -v    no effect (deprecated)<\/code><\/pre>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440\u044b<\/h2>\n<pre><code>package response  import ( \"bytes\" \"encoding\/json\" \"net\/http\" )  \/\/ JSON marshals v to JSON, automatically escaping HTML, \/\/ setting the Content-Type header as \"application\/json; charset=utf-8\", \/\/ sends an HTTP response header with the provided statusCode and \/\/ writes the marshaled v as bytes to the connection as part of an HTTP reply. func JSON(w http.ResponseWriter, statusCode int, v any) { var buf bytes.Buffer enc := json.NewEncoder(&amp;buf) enc.SetEscapeHTML(true) if err := enc.Encode(v); err != nil { http.Error(w, err.Error(), 500) return } w.Header().Set(\"Content-Type\", \"application\/json; charset=utf-8\") w.WriteHeader(statusCode) if _, err := w.Write(buf.Bytes()); err != nil { http.Error(w, err.Error(), 500) return } }<\/code><\/pre>\n<pre><code>usestdlibvars .\/...<\/code><\/pre>\n<pre><code>response.go:18:30: \"500\" can be replaced by http.StatusInternalServerError response.go:24:30: \"500\" can be replaced by http.StatusInternalServerError<\/code><\/pre>\n<h2>\u041f\u043b\u0430\u043d\u044b \u043d\u0430\u00a0\u0431\u0443\u0434\u0443\u0449\u0435\u0435<\/h2>\n<p>\u041c\u044b\u00a0\u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432\u00a0\u044f\u0437\u044b\u043a\u0435. \u0415\u0441\u043b\u0438 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u00a0\u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043c\u044b\u00a0\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043b\u0438\u043d\u0442\u0435\u0440\u0430. \u0412\u044b\u00a0\u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u0432\u043a\u043b\u0430\u0434 \u0438\u00a0\u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0442\u044c \u043d\u0430\u043c \u043f\u0443\u043b-\u0440\u0435\u043a\u0432\u0435\u0441\u0442\u044b.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/company\/evrone\/blog\/689606\/\"> https:\/\/habr.com\/ru\/company\/evrone\/blog\/689606\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-338640","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/338640","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=338640"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/338640\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=338640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=338640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=338640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}