{"id":478954,"date":"2026-05-07T13:47:58","date_gmt":"2026-05-07T13:47:58","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=478954"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=478954","title":{"rendered":"\u041a\u043e\u043d\u0444\u0438\u0433 \u0432 Go: \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043c\u043d\u043e\u0433\u043e, \u00ab\u0435\u0434\u0438\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u00bb \u043d\u0435\u0442"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0427\u0442\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u0445, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0434\u043e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u0442\u044c YAML, <code>.env<\/code>, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 <code>Config<\/code>.<\/p>\n<hr\/>\n<p>\u0412\u043e\u0442 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0431\u044b\u0442\u043e\u0432\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f. \u0415\u0441\u0442\u044c <code>config.yaml<\/code> \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u043a\u0438. \u0415\u0441\u0442\u044c <code>.env.example<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u0443\u0442\u044c \u0441\u0432\u043e\u0439. \u0412 \u043f\u0440\u043e\u0434\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u0435\u0442\u0430\u044e\u0442 \u0447\u0435\u0440\u0435\u0437 Docker\/Kubernetes\/systemd. \u0412 \u043a\u043e\u0434\u0435 \u0436\u0438\u0432\u0435\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 <code>Config<\/code>, \u0430 \u043d\u0435 \u043f\u043b\u043e\u0441\u043a\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043d\u044f.<\/p>\n<p>\u0418 \u0432\u043e\u0442 \u0432 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u044f\u0441\u043d\u043e: \u0432 Go \u043d\u0435\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u00ab\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0433\u043e\u00bb \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0435\u0437 \u043f\u043b\u044f\u0441\u043e\u043a \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u044e \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0446\u0435\u043b\u0438\u043a\u043e\u043c.<\/p>\n<p>\u042d\u0442\u043e \u043d\u0435 \u043d\u0430\u0435\u0437\u0434 \u043d\u0430 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u0412 \u043d\u0435\u0439 \u043c\u043d\u043e\u0433\u043e \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c: \u043f\u043e\u0447\u0442\u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u0440\u0435\u0448\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 \u043a\u0443\u0441\u043e\u043a, \u0430 \u0448\u0432\u044b \u043c\u0435\u0436\u0434\u0443 \u043a\u0443\u0441\u043a\u0430\u043c\u0438 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0435.<\/p>\n<hr\/>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435<\/h3>\n<p>\u0412 \u043a\u043e\u0434\u0435:<\/p>\n<pre><code class=\"go\">type Config struct {    HTTP struct {        Listen string        TLS    bool    }    Database struct {        URL string    }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 <code>docker-compose.yml<\/code> \u2014 <code>http.listen<\/code>. \u0412 Kubernetes \u2014 <code>HTTP_LISTEN<\/code>. \u0412 YAML \u043a\u0442\u043e-\u0442\u043e \u043f\u0438\u0448\u0435\u0442 <code>database.url<\/code>. \u041f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 PostgreSQL \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u043e\u0432\u0435\u0442\u0443\u0435\u0442 <code>DATABASE_URL<\/code>.<\/p>\n<p>\u0412\u0441\u0435 \u043f\u0440\u0430\u0432\u044b. \u041d\u043e \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0443 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043b\u0435\u0433\u0447\u0435.<\/p>\n<p>\u0415\u043c\u0443 \u043d\u0443\u0436\u043d\u043e:<\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043b\u0438\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0432 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0431\u0435\u0437 \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0430\u0434\u0430 \u0438\u0437 <code>os.Getenv<\/code> \u0438 <code>strconv<\/code>.<\/p>\n<\/li>\n<\/ol>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u00ab\u043a\u043e\u043d\u0444\u0438\u0433\u00bb \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0438 \u0440\u0430\u0437\u0432\u0430\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0442\u0440\u0438.<\/p>\n<hr\/>\n<h3>\u0427\u0442\u043e \u044f \u043d\u0430\u0437\u044b\u0432\u0430\u044e \u00ab\u0435\u0434\u0438\u043d\u044b\u043c\u00bb \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c<\/h3>\n<p>\u0414\u043b\u044f \u0441\u0435\u0431\u044f \u044f \u0434\u0435\u0440\u0436\u0443 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0447\u0435\u043a-\u043b\u0438\u0441\u0442:<\/p>\n<ul>\n<li>\n<p><strong>\u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432<\/strong> \u2014 YAML\/JSON\/INI\/dotenv.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043b\u043e\u0438 \u0438 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u044b<\/strong> \u2014 defaults &lt; repo config &lt; local override &lt; process env (\u043f\u043e \u043b\u043e\u0433\u0438\u043a\u0435 <a href=\"https:\/\/12factor.net\/config\" rel=\"noopener noreferrer nofollow\">12-factor<\/a>).<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439<\/strong> \u2014 \u0447\u0442\u043e\u0431\u044b <code>sub-service<\/code>, <code>sub_service<\/code> \u0438 <code>SUB_SERVICE<\/code> \u0436\u0438\u043b\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0438\u0440\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u0414\u0435\u043a\u043e\u0434 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b<\/strong> \u2014 \u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u044d\u0442\u043e <code>Config<\/code>, \u0430 \u043d\u0435 <code>map<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430<\/strong> \u2014 \u0443\u043c\u0435\u0442\u044c \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u043d\u0444\u0438\u0433 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u0444\u0430\u0439\u043b.<\/p>\n<\/li>\n<li>\n<p><strong>CLI \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043a\u0438<\/strong> \u2014 \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 <code>cmd\/*<\/code> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043c\u0435\u043b\u043e\u0447\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c<\/strong> \u2014 \u0431\u0435\u0437 \u0441\u043a\u0440\u044b\u0442\u044b\u0445 \u0433\u043b\u043e\u0431\u0430\u043b\u043e\u0432, \u0441 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u044b\u043c merge-\u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u0430\u0436\u043d\u043e: \u044d\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442 \u00ab\u043e\u0434\u043d\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043e\u0431\u044f\u0437\u0430\u043d\u0430 \u0443\u043c\u0435\u0442\u044c \u0432\u0441\u0451\u00bb. \u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 2-3 \u043f\u0443\u043d\u043a\u0442\u0430. \u041d\u0435\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u0432 README \u043e\u0431\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u00ab\u043f\u043e\u043b\u043d\u044b\u0439 \u0446\u0438\u043a\u043b\u00bb, \u0430 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043a\u0435\u0439\u0441\u044b \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u00ab\u0434\u043e\u0433\u0430\u0434\u0430\u0439\u0442\u0435\u0441\u044c \u0441\u0430\u043c\u0438\u00bb.<\/p>\n<hr\/>\n<h3>\u041a\u0440\u0430\u0442\u043a\u043e \u043f\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c<\/h3>\n<h4>Viper<\/h4>\n<p><a href=\"https:\/\/github.com\/spf13\/viper\" rel=\"noopener noreferrer nofollow\">Viper<\/a> \u2014 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u0443 \u043c\u043d\u043e\u0433\u0438\u0445. \u0411\u043e\u043b\u044c\u0448\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e, \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 API.<\/p>\n<p>\u0413\u0434\u0435 \u0431\u043e\u043b\u044c: \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 env-\u043a\u043b\u044e\u0447\u0438 \u0438 \u0441\u0432\u044f\u0437\u043a\u0430 <code>AutomaticEnv<\/code> + <code>SetEnvKeyReplacer<\/code> + <code>BindEnv<\/code>. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u0438 \u0434\u0430\u0432\u043d\u044f\u044f, \u044d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u043f\u043e \u0442\u0440\u0435\u0434\u0430\u043c \u0432\u0440\u043e\u0434\u0435 <a href=\"https:\/\/github.com\/spf13\/viper\/issues\/641\" rel=\"noopener noreferrer nofollow\">#641<\/a> \u0438 <a href=\"https:\/\/github.com\/spf13\/viper\/issues\/2001\" rel=\"noopener noreferrer nofollow\">#2001<\/a>.<\/p>\n<p>\u0418\u0442\u043e\u0433: \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0443\u0436\u0435 \u043d\u0430 \u043d\u0435\u043c. \u041d\u043e \u0441 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u043c \u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u043c env-layout \u043d\u0443\u0436\u043d\u0430 \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d\u0430.<\/p>\n<h4>Koanf<\/h4>\n<p><a href=\"https:\/\/github.com\/knadh\/koanf\" rel=\"noopener noreferrer nofollow\">Koanf<\/a> \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0431\u043e\u043b\u0435\u0435 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u0430\u044f \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f: providers, parsers, \u044f\u0432\u043d\u044b\u0439 merge-\u043f\u043e\u0440\u044f\u0434\u043e\u043a.<\/p>\n<p>\u041f\u043b\u044e\u0441: \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u0435\u043d. \u041c\u0438\u043d\u0443\u0441: \u0447\u0430\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043d\u0430 \u0432\u0430\u0441 (\u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439, \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f \u043f\u043e env, \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0434\u0435\u043a\u043e\u0434\u0430).<\/p>\n<h4>Env-first \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/h4>\n<p><a href=\"https:\/\/github.com\/caarlos0\/env\" rel=\"noopener noreferrer nofollow\">caarlos0\/env<\/a>, <a href=\"https:\/\/github.com\/kelseyhightower\/envconfig\" rel=\"noopener noreferrer nofollow\">envconfig<\/a>, <a href=\"https:\/\/github.com\/ilyakaznacheev\/cleanenv\" rel=\"noopener noreferrer nofollow\">cleanenv<\/a> \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0438\u0441\u0442\u0438\u043d\u044b \u2014 env, \u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 <code>Config<\/code>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u0443 \u0432\u0430\u0441 YAML + env + \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0435\u0432, \u043e\u043d\u0438 \u043d\u0435 \u0434\u0430\u0434\u0443\u0442 \u0432\u0435\u0441\u044c \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 \u00ab\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438\u00bb. \u041d\u0443\u0436\u0435\u043d \u043a\u043b\u0435\u0439.<\/p>\n<h4>Dotenv-\u043f\u0430\u0440\u0441\u0435\u0440\u044b<\/h4>\n<p><a href=\"https:\/\/github.com\/joho\/godotenv\" rel=\"noopener noreferrer nofollow\">joho\/godotenv<\/a> \u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u043e\u0432\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u043e: \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0447\u0438\u0442\u0430\u0435\u0442 <code>.env<\/code>.<\/p>\n<p>\u042d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043a\u0438\u0440\u043f\u0438\u0447. \u041d\u043e \u043d\u0435 \u0446\u0435\u043b\u044b\u0439 \u0434\u043e\u043c.<\/p>\n<h4>\u00ab\u041f\u0440\u043e\u0441\u0442\u043e \u043f\u0430\u0440\u0441\u0435\u0440\u044b\u00bb<\/h4>\n<p><a href=\"https:\/\/pkg.go.dev\/encoding\/json\" rel=\"noopener noreferrer nofollow\">encoding\/json<\/a>, <a href=\"https:\/\/github.com\/go-yaml\/yaml\" rel=\"noopener noreferrer nofollow\">gopkg.in\/yaml.v3<\/a>, INI-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u2014 \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u043f\u0430\u0440\u0441\u0435\u0440\u044b.<\/p>\n<p>\u041d\u043e \u043e\u043d\u0438 \u043d\u0435 \u0440\u0435\u0448\u0430\u044e\u0442 \u0441\u0430\u043c\u0438 \u043f\u043e \u0441\u0435\u0431\u0435:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043b\u043e\u0435\u0432,<\/p>\n<\/li>\n<li>\n<p>env-override,<\/p>\n<\/li>\n<li>\n<p>\u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u043c\u0435\u043d \u043a\u043b\u044e\u0447\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<h4>mapstructure<\/h4>\n<p><a href=\"https:\/\/github.com\/go-viper\/mapstructure\" rel=\"noopener noreferrer nofollow\">go-viper\/mapstructure<\/a> (v2) \u2014 \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043c\u043e\u0441\u0442 \u0438\u0437 <code>map[string]any<\/code> \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443.<\/p>\n<p>\u042d\u0442\u043e \u043d\u0435 \u043f\u0430\u0440\u0441\u0435\u0440 \u0438 \u043d\u0435 merge-\u0434\u0432\u0438\u0436\u043e\u043a. \u0415\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u0434\u0435\u043a\u043e\u0434. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0435\u0437 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u0439 \u00ab\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u044b\u00bb (\u043e \u043d\u0435\u0439 \u043d\u0438\u0436\u0435) \u043c\u0430\u0433\u0438\u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<hr\/>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u2014 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u0442\u0435\u0441\u0442<\/h3>\n<p>\u041d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0451 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0440\u0430\u0441\u0438\u0432\u043e. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442, \u043a\u043e\u0433\u0434\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439:<\/p>\n<ul>\n<li>\n<p><strong>Embedding \/ <\/strong><code><strong>squash<\/strong><\/code>: \u0433\u0434\u0435-\u0442\u043e \u043f\u043e\u043b\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u00ab\u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f\u00bb, \u0433\u0434\u0435-\u0442\u043e \u0436\u0438\u0442\u044c \u0432 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0433\u043e\u0432 \u043d\u0430 \u043e\u0434\u043d\u043e \u043f\u043e\u043b\u0435<\/strong>: <code>json<\/code>, <code>yaml<\/code>, <code>mapstructure<\/code>, \u0438\u043d\u043e\u0433\u0434\u0430 <code>env<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043f\u0438\u0441\u043a\u0438 \u0432 env<\/strong>: <code>a,b,c<\/code>, JSON-\u0441\u0442\u0440\u043e\u043a\u0430, \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u2014 \u0443 \u0432\u0441\u0435\u0445 \u0441\u0432\u043e\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043b\u0430\u0431\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f<\/strong>: \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u043d\u0430 \u0441\u0442\u044b\u043a\u0435 <code>any<\/code>, <code>float64<\/code>, yaml-\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 env-\u0441\u0442\u0440\u043e\u043a.<\/p>\n<\/li>\n<li>\n<p><code><strong>*Section<\/strong><\/code><strong> vs value<\/strong>: \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043a\u043b\u044e\u0447\u0430, \u043f\u0443\u0441\u0442\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 <code>nil<\/code> \u2014 \u043d\u0435 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u00abJSON \u0432 env\u00bb<\/strong>: \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u043e\u0441\u0442\u044b\u043b\u044c, \u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0431\u043e\u043b\u044c\u043d\u043e\u0439 \u0432 \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0430\u0446\u0438\u0438 (\u043a\u0430\u0432\u044b\u0447\u043a\u0438, \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435).<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0448\u0438\u043a\u0430\u0440\u043d\u0430 \u043d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u043c env, \u043d\u043e \u0441\u044b\u043f\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0434\u0435\u0440\u0435\u0432\u044c\u044f\u0445 \u2014 \u044d\u0442\u043e \u043d\u0435 \u00ab\u043f\u043b\u043e\u0445\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u00bb. \u041f\u0440\u043e\u0441\u0442\u043e \u0435\u0435 \u0437\u043e\u043d\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0440\u0443\u0433\u0430\u044f.<\/p>\n<hr\/>\n<h3>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0430\u044f \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0430: map \u0432 \u0446\u0435\u043d\u0442\u0440\u0435 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430<\/h3>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0435\u0437\u0434\u0435 \u0440\u0430\u0431\u043e\u0447\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code>bytes -&gt; nested map[string]any -&gt; mapstructure -&gt; struct<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041b\u0435\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u2014 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432. \u041f\u0440\u0430\u0432\u0430\u044f \u2014 \u0434\u0435\u043a\u043e\u0434 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443. \u0410 \u0432\u043e\u0442 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0443 (merge + \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439) \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0447\u0430\u0441\u0442\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442 \u0441\u0430\u043c\u0438 \u0438 \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u043e\u0444\u043e\u0440\u043c\u0438\u0442\u044c:<\/p>\n<ul>\n<li>\n<p><strong>\u041e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u0434\u043b\u044f \u043a\u0440\u043e\u0441\u0441-\u0444\u043e\u0440\u043c\u0430\u0442\u043d\u043e\u0439 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438<\/strong> (<code>sub-service<\/code> == <code>SUB_SERVICE<\/code> \u043f\u043e\u0441\u043b\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438).<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0435 \u0442\u0435\u0441\u0442\u044b<\/strong> (\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c merged-map \u0434\u043e \u0434\u0435\u043a\u043e\u0434\u0430).<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 CLI<\/strong> (<code>convert<\/code>, <code>merge<\/code>, <code>get<\/code> \u2014 \u044d\u0442\u043e \u043f\u043e \u0441\u0443\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u043e\u043a\u0440\u0443\u0433 \u0442\u043e\u0439 \u0436\u0435 map).<\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e \u043d\u0435 \u043f\u0440\u0438\u0437\u044b\u0432 \u00ab\u0432\u0441\u0451 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 map\u00bb. \u042d\u0442\u043e \u043f\u0440\u0438\u0437\u044b\u0432 \u0447\u0435\u0441\u0442\u043d\u043e \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u0442\u0430\u043f, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<hr\/>\n<h3>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0432\u044b\u0432\u043e\u0434<\/h3>\n<p>\u0423\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0439 \u00ab\u0441\u0435\u0440\u0435\u0431\u0440\u044f\u043d\u043e\u0439 \u043f\u0443\u043b\u0438\u00bb \u043d\u0435\u0442. \u0415\u0441\u0442\u044c \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u0442\u043e\u0433\u043e, <strong>\u043a\u0430\u043a\u0438\u043c \u0441\u043b\u043e\u0435\u043c \u0432\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u0441\u0430\u043c\u0438<\/strong>, \u0430 \u0447\u0442\u043e \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435.<\/p>\n<p>\u0414\u0432\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u044f\u0442 \u0432\u0440\u0435\u043c\u044f:<\/p>\n<ol>\n<li>\n<p><strong>\u0421\u0440\u0430\u0437\u0443 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0439\u0442\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u0432 \u0438 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439.<\/strong> \u041d\u0435 \u00ab\u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u043d\u0435\u0442 \u0433\u043e\u0440\u0435\u0442\u044c\u00bb, \u0430 \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0434\u0435\u043d\u044c.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0434\u0435\u043b\u0430\u0439\u0442\u0435 merge + normalizer \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c, \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u043c \u0441\u043b\u043e\u0435\u043c.<\/strong> \u042d\u0442\u043e \u0447\u0430\u0449\u0435 \u043e\u043a\u0443\u043f\u0430\u0435\u0442\u0441\u044f \u0441\u0438\u043b\u044c\u043d\u0435\u0435, \u0447\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e.<\/p>\n<\/li>\n<\/ol>\n<hr\/>\n<h3>\u0413\u0434\u0435 \u0437\u0434\u0435\u0441\u044c go-config<\/h3>\n<p><a href=\"https:\/\/github.com\/eslider\/go-config\" rel=\"noopener noreferrer nofollow\">go-config<\/a> \u2014 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0443 \u00ab\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0443\u00bb \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0439:<\/p>\n<ul>\n<li>\n<p>\u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 <code>Codec<\/code>-\u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u043b\u044f <code>env<\/code>, <code>yaml<\/code>, <code>json<\/code>, <code>ini<\/code>;<\/p>\n<\/li>\n<li>\n<p>deep merge \u0434\u043b\u044f map \u0438 last-write-wins \u0434\u043b\u044f \u0441\u043a\u0430\u043b\u044f\u0440\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 <code>LowerAlnum<\/code>;<\/p>\n<\/li>\n<li>\n<p>CLI <code>envc<\/code> \u0434\u043b\u044f <code>convert \/ get \/ merge<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043b\u044e\u0441: \u043f\u0430\u043a\u0435\u0442 <code>env<\/code> \u0443\u043c\u0435\u0435\u0442 \u0441\u043b\u043e\u0438\u0442\u044c dotenv-\u0444\u0430\u0439\u043b\u044b \u0438 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c <code><strong>WithCurrentEnvironment()<\/strong><\/code>. \u042d\u0442\u043e \u0431\u0435\u0440\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 (<code>os.Environ()<\/code> \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 <code>Map<\/code>) \u043a\u0430\u043a \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0441\u043b\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0434\u043d\u0430 \u0438 \u0442\u0430 \u0436\u0435 \u0441\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u0438 \u0432 Docker\/Kubernetes.<\/p>\n<p>\u042d\u0442\u043e \u043d\u0435 \u00ab\u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c\u00bb. \u042d\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435.<\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 API \u2014 \u0432 <a href=\"https:\/\/github.com\/eSlider\/go-config\/blob\/main\/README.md\" rel=\"noopener noreferrer nofollow\">README<\/a>. \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u2014 \u0432 <a href=\"https:\/\/github.com\/eSlider\/go-config\/blob\/main\/docs\/asr\/README.md\" rel=\"noopener noreferrer nofollow\">ASR<\/a>.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u0441\u044b\u043b\u043a\u0438<\/summary>\n<div class=\"spoiler__content\">\n<ul>\n<li>\n<p>12-factor \u2014 Config: <a href=\"https:\/\/12factor.net\/config\" rel=\"noopener noreferrer nofollow\">https:\/\/12factor.net\/config<\/a><\/p>\n<\/li>\n<li>\n<p>Awesome Go \u2014 Configuration: <a href=\"https:\/\/awesome-go.com\/configuration\/\" rel=\"noopener noreferrer nofollow\">https:\/\/awesome-go.com\/configuration\/<\/a><\/p>\n<\/li>\n<li>\n<p>Viper: <a href=\"https:\/\/github.com\/spf13\/viper\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/spf13\/viper<\/a><\/p>\n<\/li>\n<li>\n<p>Viper issue #641 \u2014 nested env binding: <a href=\"https:\/\/github.com\/spf13\/viper\/issues\/641\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/spf13\/viper\/issues\/641<\/a><\/p>\n<\/li>\n<li>\n<p>Viper issue #2001 \u2014 nested struct decode from env: <a href=\"https:\/\/github.com\/spf13\/viper\/issues\/2001\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/spf13\/viper\/issues\/2001<\/a><\/p>\n<\/li>\n<li>\n<p>Koanf: <a href=\"https:\/\/github.com\/knadh\/koanf\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/knadh\/koanf<\/a><\/p>\n<\/li>\n<li>\n<p>caarlos0\/env: <a href=\"https:\/\/github.com\/caarlos0\/env\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/caarlos0\/env<\/a><\/p>\n<\/li>\n<li>\n<p>kelseyhightower\/envconfig: <a href=\"https:\/\/github.com\/kelseyhightower\/envconfig\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/kelseyhightower\/envconfig<\/a><\/p>\n<\/li>\n<li>\n<p>cleanenv: <a href=\"https:\/\/github.com\/ilyakaznacheev\/cleanenv\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/ilyakaznacheev\/cleanenv<\/a><\/p>\n<\/li>\n<li>\n<p>joho\/godotenv: <a href=\"https:\/\/github.com\/joho\/godotenv\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/joho\/godotenv<\/a><\/p>\n<\/li>\n<li>\n<p>go-viper\/mapstructure (v2): <a href=\"https:\/\/github.com\/go-viper\/mapstructure\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/go-viper\/mapstructure<\/a><\/p>\n<\/li>\n<li>\n<p>encoding\/json (stdlib): <a href=\"https:\/\/pkg.go.dev\/encoding\/json\" rel=\"noopener noreferrer nofollow\">https:\/\/pkg.go.dev\/encoding\/json<\/a><\/p>\n<\/li>\n<li>\n<p>gopkg.in\/yaml.v3: <a href=\"https:\/\/github.com\/go-yaml\/yaml\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/go-yaml\/yaml<\/a><\/p>\n<\/li>\n<li>\n<p>Figment (Rust): <a href=\"https:\/\/docs.rs\/figment\/latest\/figment\/\" rel=\"noopener noreferrer nofollow\">https:\/\/docs.rs\/figment\/latest\/figment\/<\/a><\/p>\n<\/li>\n<li>\n<p>go-config \u2014 README: <a href=\"https:\/\/github.com\/eSlider\/go-config\/blob\/main\/README.md\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/eSlider\/go-config\/blob\/main\/README.md<\/a><\/p>\n<\/li>\n<li>\n<p>go-config \u2014 ASR index: <a href=\"https:\/\/github.com\/eSlider\/go-config\/blob\/main\/docs\/asr\/README.md\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/eSlider\/go-config\/blob\/main\/docs\/asr\/README.md<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/details>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1032676\/\">https:\/\/habr.com\/ru\/articles\/1032676\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0427\u0442\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u0445, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0434\u043e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u0442\u044c YAML, .env, \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 Config.\u0412\u043e\u0442 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0431\u044b\u0442\u043e\u0432\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f. \u0415\u0441\u0442\u044c config.yaml \u0434\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u043a\u0438. \u0415\u0441\u0442\u044c .env.example, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u0443\u0442\u044c \u0441\u0432\u043e\u0439. \u0412 \u043f\u0440\u043e\u0434\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u0435\u0442\u0430\u044e\u0442 \u0447\u0435\u0440\u0435\u0437 Docker\/Kubernetes\/systemd. \u0412 \u043a\u043e\u0434\u0435 \u0436\u0438\u0432\u0435\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 Config, \u0430 \u043d\u0435 \u043f\u043b\u043e\u0441\u043a\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043d\u044f.\u0418 \u0432\u043e\u0442 \u0432 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u044f\u0441\u043d\u043e: \u0432 Go \u043d\u0435\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u00ab\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0433\u043e\u00bb \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0435\u0437 \u043f\u043b\u044f\u0441\u043e\u043a \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u044e \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0446\u0435\u043b\u0438\u043a\u043e\u043c.\u042d\u0442\u043e \u043d\u0435 \u043d\u0430\u0435\u0437\u0434 \u043d\u0430 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u0412 \u043d\u0435\u0439 \u043c\u043d\u043e\u0433\u043e \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c: \u043f\u043e\u0447\u0442\u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u0440\u0435\u0448\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 \u043a\u0443\u0441\u043e\u043a, \u0430 \u0448\u0432\u044b \u043c\u0435\u0436\u0434\u0443 \u043a\u0443\u0441\u043a\u0430\u043c\u0438 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0435.\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435\u0412 \u043a\u043e\u0434\u0435:type Config struct {    HTTP struct {        Listen string        TLS    bool    }    Database struct {        URL string    }}\u0412 docker-compose.yml \u2014 http.listen. \u0412 Kubernetes \u2014 HTTP_LISTEN. \u0412 YAML \u043a\u0442\u043e-\u0442\u043e \u043f\u0438\u0448\u0435\u0442 database.url. \u041f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 PostgreSQL \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u043e\u0432\u0435\u0442\u0443\u0435\u0442 DATABASE_URL.\u0412\u0441\u0435 \u043f\u0440\u0430\u0432\u044b. \u041d\u043e \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u0443 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043b\u0435\u0433\u0447\u0435.\u0415\u043c\u0443 \u043d\u0443\u0436\u043d\u043e:\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b.\u0421\u043b\u0438\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0432 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u0432.\u0417\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0431\u0435\u0437 \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0430\u0434\u0430 \u0438\u0437 os.Getenv \u0438 strconv.\u0418\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u00ab\u043a\u043e\u043d\u0444\u0438\u0433\u00bb \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0438 \u0440\u0430\u0437\u0432\u0430\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0442\u0440\u0438.\u0427\u0442\u043e \u044f \u043d\u0430\u0437\u044b\u0432\u0430\u044e \u00ab\u0435\u0434\u0438\u043d\u044b\u043c\u00bb \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c\u0414\u043b\u044f \u0441\u0435\u0431\u044f \u044f \u0434\u0435\u0440\u0436\u0443 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0447\u0435\u043a-\u043b\u0438\u0441\u0442:\u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u2014 YAML\/JSON\/INI\/dotenv.\u0421\u043b\u043e\u0438 \u0438 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u044b \u2014 defaults &lt; repo config &lt; local override &lt; process env (\u043f\u043e \u043b\u043e\u0433\u0438\u043a\u0435 12-factor).\u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439 \u2014 \u0447\u0442\u043e\u0431\u044b sub-service, sub_service \u0438 SUB_SERVICE \u0436\u0438\u043b\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0438\u0440\u0435.\u0414\u0435\u043a\u043e\u0434 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u2014 \u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u044d\u0442\u043e Config, \u0430 \u043d\u0435 map.\u041e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430 \u2014 \u0443\u043c\u0435\u0442\u044c \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u043d\u0444\u0438\u0433 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u0444\u0430\u0439\u043b.CLI \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043a\u0438 \u2014 \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 cmd\/* \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043c\u0435\u043b\u043e\u0447\u0438.\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c \u2014 \u0431\u0435\u0437 \u0441\u043a\u0440\u044b\u0442\u044b\u0445 \u0433\u043b\u043e\u0431\u0430\u043b\u043e\u0432, \u0441 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u044b\u043c merge-\u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c.\u0412\u0430\u0436\u043d\u043e: \u044d\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442 \u00ab\u043e\u0434\u043d\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043e\u0431\u044f\u0437\u0430\u043d\u0430 \u0443\u043c\u0435\u0442\u044c \u0432\u0441\u0451\u00bb. \u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 2-3 \u043f\u0443\u043d\u043a\u0442\u0430. \u041d\u0435\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u0432 README \u043e\u0431\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u00ab\u043f\u043e\u043b\u043d\u044b\u0439 \u0446\u0438\u043a\u043b\u00bb, \u0430 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043a\u0435\u0439\u0441\u044b \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u00ab\u0434\u043e\u0433\u0430\u0434\u0430\u0439\u0442\u0435\u0441\u044c \u0441\u0430\u043c\u0438\u00bb.\u041a\u0440\u0430\u0442\u043a\u043e \u043f\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043cViperViper \u2014 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u0443 \u043c\u043d\u043e\u0433\u0438\u0445. \u0411\u043e\u043b\u044c\u0448\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e, \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 API.\u0413\u0434\u0435 \u0431\u043e\u043b\u044c: \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 env-\u043a\u043b\u044e\u0447\u0438 \u0438 \u0441\u0432\u044f\u0437\u043a\u0430 AutomaticEnv + SetEnvKeyReplacer + BindEnv. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u0438 \u0434\u0430\u0432\u043d\u044f\u044f, \u044d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u043f\u043e \u0442\u0440\u0435\u0434\u0430\u043c \u0432\u0440\u043e\u0434\u0435 #641 \u0438 #2001.\u0418\u0442\u043e\u0433: \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0443\u0436\u0435 \u043d\u0430 \u043d\u0435\u043c. \u041d\u043e \u0441 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u043c \u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u043c env-layout \u043d\u0443\u0436\u043d\u0430 \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d\u0430.KoanfKoanf \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0431\u043e\u043b\u0435\u0435 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u0430\u044f \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f: providers, parsers, \u044f\u0432\u043d\u044b\u0439 merge-\u043f\u043e\u0440\u044f\u0434\u043e\u043a.\u041f\u043b\u044e\u0441: \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u0435\u043d. \u041c\u0438\u043d\u0443\u0441: \u0447\u0430\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043d\u0430 \u0432\u0430\u0441 (\u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439, \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f \u043f\u043e env, \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0434\u0435\u043a\u043e\u0434\u0430).Env-first \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438caarlos0\/env, envconfig, cleanenv \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0438\u0441\u0442\u0438\u043d\u044b \u2014 env, \u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 Config.\u0415\u0441\u043b\u0438 \u0436\u0435 \u0443 \u0432\u0430\u0441 YAML + env + \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0435\u0432, \u043e\u043d\u0438 \u043d\u0435 \u0434\u0430\u0434\u0443\u0442 \u0432\u0435\u0441\u044c \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 \u00ab\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438\u00bb. \u041d\u0443\u0436\u0435\u043d \u043a\u043b\u0435\u0439.Dotenv-\u043f\u0430\u0440\u0441\u0435\u0440\u044bjoho\/godotenv \u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u043e\u0432\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u043e: \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0447\u0438\u0442\u0430\u0435\u0442 .env.\u042d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043a\u0438\u0440\u043f\u0438\u0447. \u041d\u043e \u043d\u0435 \u0446\u0435\u043b\u044b\u0439 \u0434\u043e\u043c.\u00ab\u041f\u0440\u043e\u0441\u0442\u043e \u043f\u0430\u0440\u0441\u0435\u0440\u044b\u00bbencoding\/json, gopkg.in\/yaml.v3, INI-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u2014 \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u043f\u0430\u0440\u0441\u0435\u0440\u044b.\u041d\u043e \u043e\u043d\u0438 \u043d\u0435 \u0440\u0435\u0448\u0430\u044e\u0442 \u0441\u0430\u043c\u0438 \u043f\u043e \u0441\u0435\u0431\u0435:\u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043b\u043e\u0435\u0432,env-override,\u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u043c\u0435\u043d \u043a\u043b\u044e\u0447\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u043c\u0438.mapstructurego-viper\/mapstructure (v2) \u2014 \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043c\u043e\u0441\u0442 \u0438\u0437 map[string]any \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443.\u042d\u0442\u043e \u043d\u0435 \u043f\u0430\u0440\u0441\u0435\u0440 \u0438 \u043d\u0435 merge-\u0434\u0432\u0438\u0436\u043e\u043a. \u0415\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u0434\u0435\u043a\u043e\u0434. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0435\u0437 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u0439 \u00ab\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u044b\u00bb (\u043e \u043d\u0435\u0439 \u043d\u0438\u0436\u0435) \u043c\u0430\u0433\u0438\u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.\u041f\u043e\u0447\u0435\u043c\u0443 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u2014 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u0442\u0435\u0441\u0442\u041d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0451 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0440\u0430\u0441\u0438\u0432\u043e. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442, \u043a\u043e\u0433\u0434\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439:Embedding \/ squash: \u0433\u0434\u0435-\u0442\u043e \u043f\u043e\u043b\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u00ab\u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f\u00bb, \u0433\u0434\u0435-\u0442\u043e \u0436\u0438\u0442\u044c \u0432 \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u0435.\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0433\u043e\u0432 \u043d\u0430 \u043e\u0434\u043d\u043e \u043f\u043e\u043b\u0435: json, yaml, mapstructure, \u0438\u043d\u043e\u0433\u0434\u0430 env.\u0421\u043f\u0438\u0441\u043a\u0438 \u0432 env: a,b,c, JSON-\u0441\u0442\u0440\u043e\u043a\u0430, \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u2014 \u0443 \u0432\u0441\u0435\u0445 \u0441\u0432\u043e\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430.\u0421\u043b\u0430\u0431\u0430\u044f \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u044f: \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u043d\u0430 \u0441\u0442\u044b\u043a\u0435 any, float64, yaml-\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 env-\u0441\u0442\u0440\u043e\u043a.*Section vs value: \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043a\u043b\u044e\u0447\u0430, \u043f\u0443\u0441\u0442\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 nil \u2014 \u043d\u0435 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435.\u00abJSON \u0432 env\u00bb: \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u043e\u0441\u0442\u044b\u043b\u044c, \u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0431\u043e\u043b\u044c\u043d\u043e\u0439 \u0432 \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0430\u0446\u0438\u0438 (\u043a\u0430\u0432\u044b\u0447\u043a\u0438, \u044d\u043a\u0440\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435).\u0415\u0441\u043b\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0448\u0438\u043a\u0430\u0440\u043d\u0430 \u043d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u043c env, \u043d\u043e \u0441\u044b\u043f\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0434\u0435\u0440\u0435\u0432\u044c\u044f\u0445 \u2014 \u044d\u0442\u043e \u043d\u0435 \u00ab\u043f\u043b\u043e\u0445\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u00bb. \u041f\u0440\u043e\u0441\u0442\u043e \u0435\u0435 \u0437\u043e\u043d\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0440\u0443\u0433\u0430\u044f.\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0430\u044f \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0430: map \u0432 \u0446\u0435\u043d\u0442\u0440\u0435 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0435\u0437\u0434\u0435 \u0440\u0430\u0431\u043e\u0447\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:bytes -&gt; nested map[string]any -&gt; mapstructure -&gt; struct\u041b\u0435\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u2014 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432. \u041f\u0440\u0430\u0432\u0430\u044f \u2014 \u0434\u0435\u043a\u043e\u0434 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443. \u0410 \u0432\u043e\u0442 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0443 (merge + \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439) \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0447\u0430\u0441\u0442\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442 \u0441\u0430\u043c\u0438 \u0438 \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443.\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u043e\u0444\u043e\u0440\u043c\u0438\u0442\u044c:\u041e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u0434\u043b\u044f \u043a\u0440\u043e\u0441\u0441-\u0444\u043e\u0440\u043c\u0430\u0442\u043d\u043e\u0439 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438 (sub-service == SUB_SERVICE \u043f\u043e\u0441\u043b\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438).\u041f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0435 \u0442\u0435\u0441\u0442\u044b (\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c merged-map \u0434\u043e \u0434\u0435\u043a\u043e\u0434\u0430).\u041f\u0440\u043e\u0441\u0442\u043e\u0439 CLI (convert, merge, get \u2014 \u044d\u0442\u043e \u043f\u043e \u0441\u0443\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u043e\u043a\u0440\u0443\u0433 \u0442\u043e\u0439 \u0436\u0435 map).\u042d\u0442\u043e \u043d\u0435 \u043f\u0440\u0438\u0437\u044b\u0432 \u00ab\u0432\u0441\u0451 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 map\u00bb. \u042d\u0442\u043e \u043f\u0440\u0438\u0437\u044b\u0432 \u0447\u0435\u0441\u0442\u043d\u043e \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u0442\u0430\u043f, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0432\u044b\u0432\u043e\u0434\u0423\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0439 \u00ab\u0441\u0435\u0440\u0435\u0431\u0440\u044f\u043d\u043e\u0439 \u043f\u0443\u043b\u0438\u00bb \u043d\u0435\u0442. \u0415\u0441\u0442\u044c \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u0438\u043c \u0441\u043b\u043e\u0435\u043c \u0432\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u0441\u0430\u043c\u0438, \u0430 \u0447\u0442\u043e \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435.\u0414\u0432\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u044f\u0442 \u0432\u0440\u0435\u043c\u044f:\u0421\u0440\u0430\u0437\u0443 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0439\u0442\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u0432 \u0438 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439. \u041d\u0435 \u00ab\u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u043d\u0435\u0442 \u0433\u043e\u0440\u0435\u0442\u044c\u00bb, \u0430 \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0434\u0435\u043d\u044c.\u0421\u0434\u0435\u043b\u0430\u0439\u0442\u0435 merge + normalizer \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c, \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u043c \u0441\u043b\u043e\u0435\u043c. \u042d\u0442\u043e \u0447\u0430\u0449\u0435 \u043e\u043a\u0443\u043f\u0430\u0435\u0442\u0441\u044f \u0441\u0438\u043b\u044c\u043d\u0435\u0435, \u0447\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u0443\u044e.\u0413\u0434\u0435 \u0437\u0434\u0435\u0441\u044c go-configgo-config \u2014 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0443 \u00ab\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0443\u00bb \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0439:\u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 Codec-\u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u043b\u044f env, yaml, json, ini;deep merge \u0434\u043b\u044f map \u0438 last-write-wins \u0434\u043b\u044f \u0441\u043a\u0430\u043b\u044f\u0440\u043e\u0432;\u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 LowerAlnum;CLI envc \u0434\u043b\u044f convert \/ get \/ merge.\u0414\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043b\u044e\u0441: \u043f\u0430\u043a\u0435\u0442 env \u0443\u043c\u0435\u0435\u0442 \u0441\u043b\u043e\u0438\u0442\u044c dotenv-\u0444\u0430\u0439\u043b\u044b \u0438 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c WithCurrentEnvironment(). \u042d\u0442\u043e \u0431\u0435\u0440\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 (os.Environ() \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 Map) \u043a\u0430\u043a \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0441\u043b\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0434\u043d\u0430 \u0438 \u0442\u0430 \u0436\u0435 \u0441\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u0438 \u0432 Docker\/Kubernetes.\u042d\u0442\u043e \u043d\u0435 \u00ab\u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c\u00bb. \u042d\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435.\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 API \u2014 \u0432 README. \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u2014 \u0432 ASR.\u0421\u0441\u044b\u043b\u043a\u043812-factor \u2014 Config: https:\/\/12factor.net\/configAwesome Go \u2014 Configuration: https:\/\/awesome-go.com\/configuration\/Viper: https:\/\/github.com\/spf13\/viperViper issue #641 \u2014 nested env binding: https:\/\/github.com\/spf13\/viper\/issues\/641Viper issue #2001 \u2014 nested struct decode from env: https:\/\/github.com\/spf13\/viper\/issues\/2001Koanf: https:\/\/github.com\/knadh\/koanfcaarlos0\/env: https:\/\/github.com\/caarlos0\/envkelseyhightower\/envconfig: https:\/\/github.com\/kelseyhightower\/envconfigcleanenv: https:\/\/github.com\/ilyakaznacheev\/cleanenvjoho\/godotenv: https:\/\/github.com\/joho\/godotenvgo-viper\/mapstructure (v2): https:\/\/github.com\/go-viper\/mapstructureencoding\/json (stdlib): https:\/\/pkg.go.dev\/encoding\/jsongopkg.in\/yaml.v3: https:\/\/github.com\/go-yaml\/yamlFigment (Rust): https:\/\/docs.rs\/figment\/latest\/figment\/go-config \u2014 README: https:\/\/github.com\/eSlider\/go-config\/blob\/main\/README.mdgo-config \u2014 ASR index: https:\/\/github.com\/eSlider\/go-config\/blob\/main\/docs\/asr\/README.md\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 https:\/\/habr.com\/ru\/articles\/1032676\/<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-478954","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/478954","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=478954"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/478954\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=478954"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=478954"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=478954"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}