{"id":475460,"date":"2025-09-17T11:11:50","date_gmt":"2025-09-17T11:11:50","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=475460"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=475460","title":{"rendered":"\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u0432 Go: \u043a\u0430\u043a \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0444\u043b\u0430\u043a\u043e\u0432 \u0438 \u0431\u043e\u043b\u0438"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u0413\u043e\u043b\u0443\u0431\u044c, \u0438 \u044f \u043f\u0438\u0448\u0443 \u043d\u0430 Go \u0443\u0436\u0435 7 \u043b\u0435\u0442. \u041a\u043e\u0433\u0434\u0430 \u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u043b, \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u044b, \u0441\u0431\u043e\u0440\u043a\u0430 \u0437\u0435\u043b\u0451\u043d\u0430\u044f \u2014 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u043b\u0438\u0437\u0438\u0442\u044c. \u041d\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0436\u0435 \u0431\u043e\u0435\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u044d\u0442\u043e \u0438\u043b\u043b\u044e\u0437\u0438\u044f. \u0412 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435 \u0432\u0441\u0451 \u043f\u0430\u0434\u0430\u0435\u0442, \u0445\u043e\u0442\u044f \u044e\u043d\u0438\u0442\u044b \u0441\u0438\u044f\u044e\u0442 \u0437\u0435\u043b\u0451\u043d\u044b\u043c. \u041f\u043e\u0447\u0435\u043c\u0443? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u2014 \u044d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0434, \u043d\u043e \u0438 PostgreSQL, Redis, Kafka, \u0432\u043d\u0435\u0448\u043d\u0438\u0435 API. \u0414\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0447\u0435\u0440\u0435\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u0438 \u043b\u044e\u0431\u0430\u044f \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u043b\u043e\u043c\u0430\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u042e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043b\u043e\u0432\u044f\u0442. \u0422\u0443\u0442 \u043d\u0443\u0436\u043d\u044b \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435.<\/p>\n<div class=\"persona\"><img decoding=\"async\" class=\"image persona__image\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b9a\/315\/9a2\/b9a3159a219d83f7170fdbd78cfa3636.jpg\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/b9a\/315\/9a2\/b9a3159a219d83f7170fdbd78cfa3636.jpg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b9a\/315\/9a2\/b9a3159a219d83f7170fdbd78cfa3636.jpg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<h5 class=\"persona__heading\">\u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u0413\u043e\u043b\u0443\u0431\u044c<\/h5>\n<p class=\"persona__text\">\u0420\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u0433\u0440\u0443\u043f\u043f\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432 \u0421\u0438\u043c\u0430-\u043b\u0435\u043d\u0434\u0435, \u0441\u043e\u0430\u0432\u0442\u043e\u0440 \u043a\u0443\u0440\u0441\u0430 \u043f\u043e Golang \u0432 \u041d\u0435\u0442\u043e\u043b\u043e\u0433\u0438\u0438<\/p>\n<\/div>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u0440\u0435\u0434\u043a\u043e \u043f\u0438\u0448\u0443\u0442 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u041c\u043d\u043e\u0433\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442 \u0438\u0445 \u043d\u0430 \u043f\u043e\u0442\u043e\u043c, \u0441\u0447\u0438\u0442\u0430\u044f \u043b\u0438\u0448\u043d\u0438\u043c\u0438 \u0437\u0430\u0442\u0440\u0430\u0442\u0430\u043c\u0438. \u041d\u0430 \u0434\u0435\u043b\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d\u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u043a\u0430\u043a \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0440\u0430\u0437\u0433\u043e\u0432\u0430\u0440\u0438\u0432\u0430\u044e\u0442 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c, \u043a\u0430\u043a \u0432\u0435\u0434\u0443\u0442 \u0441\u0435\u0431\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u0438 \u0432\u044b\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443. \u0418 \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u043d\u0435\u0442, \u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0437\u0430\u043b\u043e\u0436\u043d\u0438\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0441\u0442\u0435\u0439: \u0447\u0442\u043e-\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435, \u043d\u043e \u043f\u0430\u0434\u0430\u0435\u0442 \u0432 CI \u0438\u043b\u0438, \u0447\u0442\u043e \u0445\u0443\u0436\u0435, \u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430.<\/p>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043e\u0431 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u0432 Go \u2014 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e \u0442\u0435\u043e\u0440\u0438\u044e, \u0430 \u043f\u0440\u043e \u0432\u044b\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041e\u043d\u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0443\u0431\u0440\u0430\u0442\u044c \u0444\u043b\u0430\u043a\u0438, \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u0445\u0430\u043e\u0441 \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c CI \u0432 \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u0430 \u043d\u0435 \u043b\u043e\u0442\u0435\u0440\u0435\u044e.<\/p>\n<h2>\u041f\u043e\u0447\u0435\u043c\u0443 Go \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432<\/h2>\n<p>\u0412 Go \u043d\u0435\u0442 \u043c\u0430\u0433\u0438\u0438 \u0432\u0440\u043e\u0434\u0435 <code>@Transactional<\/code> \u0438\u043b\u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0444\u0438\u043a\u0441\u0442\u0443\u0440, \u043a\u0430\u043a \u0432 Java \u0438\u043b\u0438 <a href=\"https:\/\/habr.com\/ru\/companies\/netologyru\/articles\/940890\/\">Python<\/a>. \u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b, \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c \u0440\u0443\u043a\u0430\u043c\u0438. \u042f\u0437\u044b\u043a \u0434\u0430\u0451\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u044b\u0439, \u043d\u043e \u043c\u043e\u0449\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 \u2014 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 <code>testing<\/code> \u0438 \u0443\u0434\u043e\u0431\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438. \u0412\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u043a\u0440\u0443\u0433 \u044d\u0442\u043e\u0433\u043e. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043a\u0440\u044b\u0432\u0430\u044e\u0442 \u0434\u0435\u0442\u0430\u043b\u0438 \u0437\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438 \u0438\u043b\u0438 DSL, \u0432 Go \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441: \u0433\u0434\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f PostgreSQL, \u043a\u0430\u043a \u043d\u0430\u043a\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0447\u0438\u0449\u0430\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u0430 \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u0441\u0442\u0430\u043c\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u043e\u0439, \u043d\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u0430\u044f \u044f\u0432\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u0435\u0441\u0442\u044b \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u043c\u0438, \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u043c\u0438 \u0438 \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u043c\u0438. \u0415\u0441\u043b\u0438 \u0431\u0430\u0437\u0430 \u043d\u0435 \u0433\u043e\u0442\u043e\u0432\u0430, \u044d\u0442\u043e \u0432\u0438\u0434\u043d\u043e. \u0415\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0441\u044c \u2014 \u0442\u043e\u0436\u0435 \u0432\u0438\u0434\u043d\u043e.<\/p>\n<p>\u0415\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043b\u044e\u0441\u044b:<\/p>\n<ul>\n<li>\n<p><strong>\u0415\u0434\u0438\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430.<\/strong> \u0412\u0441\u0451 \u0433\u043e\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <code>go test<\/code>, \u0431\u0435\u0437 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0440\u0430\u043d\u043d\u0435\u0440\u043e\u0432 \u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u043b\u043e\u0451\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c.<\/strong> \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>t.Parallel()<\/code> \u043b\u0435\u0433\u043a\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b, \u0435\u0441\u043b\u0438 \u043a\u0430\u0436\u0434\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p><strong>\u0413\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b.<\/strong> \u0412\u044b \u0441\u0430\u043c\u0438 \u0440\u0435\u0448\u0430\u0435\u0442\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438 dockertest, Testcontainers \u0438\u043b\u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 mock-\u0441\u0435\u0440\u0432\u0435\u0440\u044b. \u041d\u0435\u0442 \u0436\u0451\u0441\u0442\u043a\u043e\u0439 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p><strong>\u0427\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c \u0432\u0434\u043e\u043b\u0433\u0443\u044e.<\/strong> \u0422\u0435\u0441\u0442\u044b \u0432 Go \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u0434: \u0431\u0435\u0437 \u0441\u043a\u0440\u044b\u0442\u044b\u0445 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0438 \u0445\u0438\u0442\u0440\u044b\u0445 \u043e\u0431\u0451\u0440\u0442\u043e\u043a. \u041b\u044e\u0431\u043e\u0439 \u043d\u043e\u0432\u0438\u0447\u043e\u043a \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u0438\u0434\u0438\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u043d\u0430 Go \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0436\u0438\u0432\u0443\u0442 \u0434\u043e\u043b\u044c\u0448\u0435 \u0438 \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u0435\u0435, \u0447\u0435\u043c \u0432 \u044f\u0437\u044b\u043a\u0430\u0445 \u0432\u0440\u043e\u0434\u0435 Python, JavaScript \u0438\u043b\u0438 Ruby, \u0433\u0434\u0435 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u043e\u0431\u044b\u0447\u043d\u043e \u0435\u0441\u0442\u044c \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0438 \u043e\u0431\u0451\u0440\u0442\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u00ab\u0434\u0435\u043b\u0430\u044e\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044e \u0443\u0434\u043e\u0431\u043d\u0435\u0435\u00bb. \u041d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u0432 \u043d\u0438\u0445 \u0431\u044b\u0441\u0442\u0440\u0435\u0435: \u043c\u043d\u043e\u0433\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043c\u043d\u043e\u0433\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0439. \u041d\u043e \u043c\u0438\u043d\u0443\u0441 \u2014 \u0442\u0430\u043a\u0438\u0435 \u0442\u0435\u0441\u0442\u044b \u043f\u043e\u0442\u043e\u043c \u0447\u0430\u0449\u0435 \u043b\u043e\u043c\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0430\u043f\u0433\u0440\u0435\u0439\u0434\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439, \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043c\u043e\u043a\u043e\u0432 \u0438 \u043a\u043e\u0441\u0442\u044b\u043b\u0435\u0439. \u0422\u0430\u043a \u0447\u0442\u043e \u0441 Go \u0432\u044b \u043f\u043b\u0430\u0442\u0438\u0442\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435, \u043d\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u0435 \u0435\u0433\u043e \u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c.<\/p>\n<h2>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0431\u043e\u043b\u044c \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u2014 \u0444\u043b\u0430\u043a\u0438<\/h2>\n<p>\u0424\u043b\u0430\u043a\u0438 \u0443\u0431\u0438\u0432\u0430\u044e\u0442 \u0434\u043e\u0432\u0435\u0440\u0438\u0435 \u043a \u0442\u0435\u0441\u0442\u0430\u043c. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435: \u0431\u0438\u043b\u0434 \u043f\u0430\u0434\u0430\u0435\u0442 \u043d\u0435 \u0438\u0437-\u0437\u0430 \u0431\u0430\u0433\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0431\u0430\u0437\u0430 \u043d\u0435 \u0443\u0441\u043f\u0435\u043b\u0430 \u043f\u043e\u0434\u043d\u044f\u0442\u044c\u0441\u044f \u0438\u043b\u0438 \u0442\u0435\u0441\u0442\u044b \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u043b\u0438\u0441\u044c \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0432\u0438\u0434\u044f\u0442 \u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0438 \u0443\u0436\u0435 \u043d\u0435 \u0434\u0443\u043c\u0430\u044e\u0442 \u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435 \u0432 \u0441\u0432\u043e\u0451\u043c \u043a\u043e\u0434\u0435 \u2014 \u0441\u043a\u043e\u0440\u0435\u0435, \u0440\u0435\u0448\u0430\u044e\u0442, \u0447\u0442\u043e CI \u043e\u043f\u044f\u0442\u044c \u0448\u0430\u043b\u0438\u0442. \u041f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0432\u044b\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u043c\u043c\u0443\u043d\u0438\u0442\u0435\u0442 \u043a \u043a\u0440\u0430\u0441\u043d\u043e\u043c\u0443: \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0442\u043e\u043d\u0443\u0442 \u0432 \u0448\u0443\u043c\u0435 \u0438 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u0430\u0433 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435\u0434\u0435\u043b\u044e \u0432\u0438\u0441\u0435\u0442\u044c \u0432 \u043c\u0430\u0441\u0442\u0435\u0440\u0435, \u043f\u043e\u043a\u0430 \u0432\u0441\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u0434\u0435\u043b\u043e \u0432 \u0442\u0435\u0441\u0442\u0430\u0445.<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0444\u043b\u0430\u043a\u0438 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0431\u044c\u044e\u0442 \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0412\u0440\u0435\u043c\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u0440\u0430\u0441\u0442\u0451\u0442 \u0437\u0430 \u0441\u0447\u0451\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u043e\u043d\u043e\u0432, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0442\u0440\u0430\u0442\u044f\u0442 \u0447\u0430\u0441\u044b \u043d\u0430 \u0432\u044b\u044f\u0441\u043d\u0435\u043d\u0438\u0435, \u00ab\u043f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u043d\u043e \u0443\u043f\u0430\u043b\u043e\u00bb, \u0430 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0441\u043e\u043c\u043d\u0435\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0430\u0434\u0451\u0436\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0418\u0442\u043e\u0433 \u2014 \u0442\u0435\u0441\u0442\u044b \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u044e\u0442 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0437\u0430\u0449\u0438\u0442\u0430 \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0431\u0443\u0437\u0443.<\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0435 \u0444\u043b\u0430\u043a\u0438 \u0440\u0430\u0437\u0440\u0443\u0448\u0430\u044e\u0442 \u043a\u0443\u043b\u044c\u0442\u0443\u0440\u0443 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435. \u0415\u0441\u043b\u0438 \u0442\u0435\u0441\u0442\u044b \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u043d\u0435\u043d\u0430\u0434\u0451\u0436\u043d\u044b\u043c\u0438, \u0442\u043e \u0438 \u043c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043f\u0430\u0434\u0430\u0435\u0442. \u0410 \u0434\u0430\u043b\u044c\u0448\u0435 \u2014 \u043f\u0440\u044f\u043c\u043e\u0439 \u043f\u0443\u0442\u044c \u043a \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u0439\u043c\u0430\u0442\u044c \u0437\u0430\u0440\u0430\u043d\u0435\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441 \u0444\u043b\u0430\u043a\u0430\u043c\u0438 \u0431\u043e\u0440\u044e\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0440\u0430\u0434\u0438 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0442\u0435\u0441\u0442\u044b \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u0449\u0438\u0449\u0430\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u044b \u0444\u043b\u0430\u043a\u043e\u0432.<\/p>\n<h3>1. \u0411\u0430\u0437\u0430 \u043d\u0435 \u0433\u043e\u0442\u043e\u0432\u0430<\/h3>\n<p>\u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0441\u044f, \u043d\u043e PostgreSQL \u0435\u0449\u0451 \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u0420\u0435\u0448\u0435\u043d\u0438\u0435: \u043d\u0435 <code>time.Sleep<\/code>, \u0430 \u0446\u0438\u043a\u043b \u0441 <code>Ping + retry<\/code>. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c <code>time.Sleep(10 * time.Second)<\/code>, \u0442\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u0441\u0451 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u2014 \u043f\u0430\u0434\u0430\u0442\u044c. \u0411\u0430\u0437\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0438 \u0437\u0430 2 \u0441\u0435\u043a\u0443\u043d\u0434\u044b, \u0438 \u0437\u0430 20, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u0436\u0435\u043b\u0435\u0437\u0430.<\/p>\n<pre><code class=\"go\">func waitForPostgres(dsn string, timeout time.Duration) error {    deadline := time.Now().Add(timeout)    ticker := time.NewTicker(500 * time.Millisecond)    defer ticker.Stop()    var lastErr error    for range ticker.C {        if time.Now().After(deadline) {            break        }        db, err := sql.Open(\"postgres\", dsn)        if err != nil {            lastErr = err            continue        }     ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)        pingErr := db.PingContext(ctx)        cancel()        _ = db.Close()        if pingErr == nil {            return nil        }        lastErr = pingErr    }    return fmt.Errorf(\"Postgres \u043d\u0435 \u043f\u043e\u0434\u043d\u044f\u043b\u0441\u044f \u0437\u0430 %s: %w\", timeout, lastErr)}<\/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>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>waitForPostgres<\/code> \u0440\u0435\u0448\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443: \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u0438 PostgreSQL \u043a \u043f\u0440\u0438\u0451\u043c\u0443 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0430\u0439\u043c-\u0430\u0443\u0442\u0430.<\/p>\n<ul>\n<li>\n<p>\u041e\u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0446\u0438\u043a\u043b \u0441 \u0442\u0438\u043a\u0435\u0440\u043e\u043c \u2014 \u043a\u0430\u0436\u0434\u044b\u0435 500 \u043c\u0441.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c <code>PingContext<\/code> \u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u0442\u0430\u0439\u043c-\u0430\u0443\u0442\u043e\u043c \u0432 2 \u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0431\u0430\u0437\u0430 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0440\u0430\u0437\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>nil<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u0438\u0441\u0442\u0435\u043a\u043b\u043e, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u0441\u0431\u043e\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 <code>time.Sleep<\/code>, \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u044c PostgreSQL \u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u043c \u0440\u043e\u0432\u043d\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0441\u0442\u0430\u043b \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d (\u0438\u043b\u0438 \u043a\u043e\u0433\u0434\u0430 \u0442\u0430\u0439\u043c-\u0430\u0443\u0442 \u0432\u044b\u0448\u0435\u043b).<\/p>\n<h3>2. \u0413\u0440\u044f\u0437\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h3>\n<p>\u0412 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0435 \u0433\u0440\u044f\u0437\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0434\u0438\u043d \u0442\u0435\u0441\u0442 \u0441\u043e\u0437\u0434\u0430\u043b \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0437\u0430\u043a\u0430\u0437\u043e\u0432, \u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043e\u0436\u0438\u0434\u0430\u043b, \u0447\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439. \u0415\u0441\u043b\u0438 \u043e\u043d\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e, \u0432\u0442\u043e\u0440\u043e\u0439 \u0442\u0435\u0441\u0442 \u0442\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442, \u0442\u043e \u043f\u0430\u0434\u0430\u0435\u0442 \u2014 \u0432\u0441\u0451 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0443\u0441\u043f\u0435\u043b \u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u0443\u0436\u0435 \u0447\u0442\u043e-\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c. \u0418\u0437-\u0437\u0430 \u0442\u0430\u043a\u043e\u0439 \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0441\u0442\u0438 \u0442\u0435\u0441\u0442 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0444\u043b\u0435\u0439\u043a\u043e\u0432\u044b\u043c (flaky, \u0438\u043b\u0438 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u043c, \u0444\u043b\u0430\u043a\u0438-\u0442\u0435\u0441\u0442\u043e\u043c) \u0438 \u0434\u043e\u0432\u0435\u0440\u0438\u0435 \u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c \u0431\u044b\u0441\u0442\u0440\u043e \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f.<\/p>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0434\u0432\u0443\u043c\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u043c\u0438:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\"><strong>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439 \u0441 \u043e\u0442\u043a\u0430\u0442\u043e\u043c (rollback)<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u2022 \u041a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0432\u043e\u0435\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438.<\/p>\n<p align=\"left\">\u2022 \u0412 \u043a\u043e\u043d\u0446\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f ROLLBACK, \u0438 \u0431\u0430\u0437\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a \u0447\u0438\u0441\u0442\u043e\u043c\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e.<\/p>\n<p align=\"left\">\u2022 \u041f\u043b\u044e\u0441: \u0431\u044b\u0441\u0442\u0440\u043e, \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u044b, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432.<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u2022 \u041a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u043f\u0443\u0441\u0442\u0443\u044e \u0431\u0430\u0437\u0443, \u0447\u0430\u0441\u0442\u043e \u0447\u0435\u0440\u0435\u0437 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 Docker.<\/p>\n<p align=\"left\">\u2022 \u0413\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n<p align=\"left\">\u2022 \u041c\u0438\u043d\u0443\u0441: \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0412\u043e\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u043a\u0430\u0442\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430:<\/p>\n<pre><code class=\"go\">func runInTx(t *testing.T, fn func(tx *sql.Tx)) {    t.Helper()    tx, err := db.Begin()    if err != nil {        t.Fatalf(\"\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0447\u0430\u0442\u044c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e: %v\", err)    }    defer func() { _ = tx.Rollback() }()    fn(tx)}func TestCreateUser(t *testing.T) {    runInTx(t, func(tx *sql.Tx) {        _, err := tx.Exec(\"INSERT INTO users(name) VALUES($1)\", \"Alice\")        if err != nil {            t.Fatalf(\"insert: %v\", err)        }        var count int        if err := tx.QueryRow(\"SELECT COUNT(*) FROM users\").Scan(&amp;count); err != nil {            t.Fatalf(\"query: %v\", err)        }        if count != 1 {            t.Errorf(\"\u041e\u0436\u0438\u0434\u0430\u043b\u0438 1 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 %d\", count)        }    })}<\/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<h3>3. \u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0449\u0438\u043d\u0430<\/h3>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u043e\u0439 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u2014 Kafka, Redis Pub\/Sub, RabbitMQ \u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435, \u2014 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e. \u041e\u0434\u0438\u043d \u0442\u0435\u0441\u0442 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u043d\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0438\u043b\u0438 \u0441\u043e\u0442\u043d\u0438 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u0440\u0430\u0437\u0443, \u0442\u0435\u0441\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0430\u0434\u0430\u0442\u044c, \u0445\u043e\u0442\u044f \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u042d\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f race condition \u0432 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430\u0445. \u041a\u0430\u043a \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u00ab\u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441\u00bb, \u0441\u043a\u0430\u0437\u0430\u0442\u044c: \u00ab\u0434\u0430\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0432\u0440\u0435\u043c\u044f, \u043d\u043e \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 N \u0441\u0435\u043a\u0443\u043d\u0434\u00bb;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>eventually<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 (<code>cond<\/code>) \u043a\u0430\u0436\u0434\u044b\u0435 200 \u043c\u0441 \u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0441\u0440\u0430\u0437\u0443, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0430 \u0432\u0435\u0440\u043d\u0451\u0442 <code>true<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430 \u043e\u0442\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0442\u0430\u043a \u0438 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u043e\u0441\u044c, \u0442\u0435\u0441\u0442 \u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439. \u041d\u0438\u0436\u0435 \u2014 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u0441 <code>eventually<\/code>:<\/p>\n<pre><code>func eventually(t *testing.T, cond func() bool, timeout time.Duration) {    t.Helper()    ticker := time.NewTicker(200 * time.Millisecond)    defer ticker.Stop()    timeoutC := time.After(timeout)    for {        select {        case &lt;-ticker.C:            if cond() {                return            }        case &lt;-timeoutC:            t.Fatalf(\"\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0437\u0430 %s\", timeout)        }    }}func TestMessageDelivered(t *testing.T) {    sendMessage(\"hello\")    eventually(t, func() bool {        msg, ok := tryReceiveMessage()        return ok &amp;&amp; msg == \"hello\"    }, 5*time.Second)}<\/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<h3>4. Shared state<\/h3>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0442\u0435\u0441\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0434\u043d\u0443 \u0411\u0414, \u043e\u0434\u0438\u043d \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 Kafka, \u043e\u0434\u0438\u043d Redis, \u2014 \u043e\u043d\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e \u0432\u043b\u0438\u044f\u0442\u044c \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430:<\/p>\n<ul>\n<li>\n<p><strong>\u0414\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0442\u0441\u044f. <\/strong>\u041e\u0434\u0438\u043d \u0442\u0435\u0441\u0442 \u0432\u0441\u0442\u0430\u0432\u0438\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f &#171;Alice&#187;, \u0434\u0440\u0443\u0433\u043e\u0439 \u043e\u0436\u0438\u0434\u0430\u043b \u043f\u0443\u0441\u0442\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u2014 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u0418\u043b\u0438 \u0434\u0432\u0430 \u0442\u0435\u0441\u0442\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c, \u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 duplicate key.<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0431\u043e\u0438 \u0438\u0437-\u0437\u0430 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. <\/strong>\u0422\u0435\u0441\u0442\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e (go test -parallel), \u0438 \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u0434\u0440\u0443\u0433\u043e\u0439 \u0438\u0445 \u0447\u0438\u0442\u0430\u0435\u0442. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0444\u043b\u0435\u0439\u043a\u043e\u0432\u044b\u0435 \u0442\u0435\u0441\u0442\u044b: \u0438\u043d\u043e\u0433\u0434\u0430 \u0437\u0435\u043b\u0451\u043d\u044b\u0435, \u0438\u043d\u043e\u0433\u0434\u0430 \u043a\u0440\u0430\u0441\u043d\u044b\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u041a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u044b \u043f\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c. <\/strong>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0441\u0442\u043e\u0432 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0442\u043e\u043f\u0438\u043a Kafka \u0438\u043b\u0438 \u043e\u0434\u0438\u043d Redis-\u043a\u0430\u043d\u0430\u043b. \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0443\u0442\u0435\u043a\u0430\u044e\u0442 \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u0441\u0442\u0430\u043c\u0438, \u0438 \u0442\u0435\u0441\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u0447\u0443\u0436\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0435\u043e\u0447\u0438\u0449\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. <\/strong>\u041e\u0434\u0438\u043d \u0442\u0435\u0441\u0442 \u0437\u0430\u0431\u044b\u043b \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043b\u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0439. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0442\u0435\u0441\u0442\u044b \u0441\u0442\u0430\u0440\u0442\u0443\u044e\u0442 \u043d\u0435 \u0441 \u043d\u0443\u043b\u044f, \u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u043c.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442 \u0432\u0438\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u043e\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u043e\u0441\u0435\u0434\u0435\u0439. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u0435\u0441\u0442\u044b \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c\u044b\u043c\u0438, \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u043c\u0438 \u0438 \u0431\u044b\u0441\u0442\u0440\u044b\u043c\u0438 \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<ul>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u2014 \u043a\u0430\u043a \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/github.com\/ory\/dockertest\">dockertest<\/a>. \u0422\u0430\u043a \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0441\u0432\u043e\u044e \u0441\u0432\u0435\u0436\u0443\u044e \u0431\u0430\u0437\u0443 \u0438\u043b\u0438 \u0431\u0440\u043e\u043a\u0435\u0440\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0445\u0435\u043c\u0443 (schema) \u0432 \u043e\u0434\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u2014 \u0442\u0435\u0441\u0442\u044b \u043d\u0435 \u043c\u0435\u0448\u0430\u044e\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430\u0445 \u0438\u043c\u0451\u043d.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"go\">func TestMain(m *testing.M) {    pool, err := dockertest.NewPool(\"\")    if err != nil {        log.Fatalf(\"docker pool: %v\", err)    }    resource, err := pool.Run(\"postgres\", \"15\", []string{        \"POSTGRES_USER=test\",        \"POSTGRES_PASSWORD=secret\",        \"POSTGRES_DB=testdb\",    })    if err != nil {        log.Fatalf(\"start postgres: %v\", err)    }    pool.MaxWait = 2 * time.Minute  dsn := fmt.Sprintf(\"postgres:\/\/test:secret@localhost:%s\/testdb?sslmode=disable\", resource.GetPort(\"5432\/tcp\"))    if err := waitForPostgres(dsn); err != nil {        log.Fatalf(\"db not ready: %v\", err)    }    db, _ = sql.Open(\"postgres\", dsn)    code := m.Run()    _ = db.Close()    _ = pool.Purge(resource)    os.Exit(code)}func TestInsert(t *testing.T) {  _, err := db.Exec(\"CREATE TABLE IF NOT EXISTS users (id SERIAL PRIMARY KEY, name TEXT)\")  if err != nil {    t.Fatalf(\"create table: %v\", err)  }  _, err = db.Exec(\"INSERT INTO users(name) VALUES($1)\", \"Alice\")  if err != nil {    t.Fatalf(\"insert: %v\", err)  }  var count int  if err := db.QueryRow(\"SELECT COUNT(*) FROM users\").Scan(&amp;count); err != nil {    t.Fatalf(\"query: %v\", err)}  if count != 1 {    t.Errorf(\"\u041e\u0436\u0438\u0434\u0430\u043b\u0438 1 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 %d\", count)  }}<\/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><strong>\u0427\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442:<\/strong><\/p>\n<ol>\n<li>\n<p>\u0412 TestMain \u043c\u044b \u0447\u0435\u0440\u0435\u0437 <code>dockertest<\/code> \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u043c \u0441\u0432\u0435\u0436\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 PostgreSQL.<\/p>\n<\/li>\n<li>\n<p><code>pool.Retry<\/code> \u043a\u0440\u0443\u0442\u0438\u0442 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f, \u043f\u043e\u043a\u0430 \u0431\u0430\u0437\u0430 \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0412 <code>defer<\/code> \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u043c, \u0447\u0442\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0447\u0438\u0441\u0442\u044b\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u0438\u043c.<\/p>\n<\/li>\n<\/ol>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u0443\u044e \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044e \u0441 PostgreSQL \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438\u0437\u0431\u0435\u0433\u0430\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c c shared state (\u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c).<\/p>\n<h2>\u0420\u0435\u0437\u044e\u043c\u0438\u0440\u0443\u0435\u043c<\/h2>\n<p>\u0412\u0434\u043e\u043b\u0433\u0443\u044e \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u044f\u0442 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0434\u0435\u043d\u044c\u0433\u0438. \u041e\u043d\u0438 \u043b\u043e\u0432\u044f\u0442 \u0442\u0435 <a href=\"https:\/\/habr.com\/ru\/companies\/netologyru\/articles\/921954\/\">\u0431\u0430\u0433\u0438<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043f\u0440\u043e\u0434\u0435 \u0432\u044b\u043b\u0438\u043b\u0438\u0441\u044c \u0431\u044b \u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0438, \u043d\u0435\u0434\u043e\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438 \u0441\u0440\u043e\u0447\u043d\u044b\u0435 \u0445\u043e\u0442\u0444\u0438\u043a\u0441\u044b. \u041a\u0430\u0436\u0434\u0430\u044f \u0442\u0430\u043a\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u2014 \u044d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u043d\u044c\u0433\u0438 \u043d\u0430 \u0432\u0435\u0442\u0435\u0440, \u043d\u043e \u0438 \u0440\u0435\u043f\u0443\u0442\u0430\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u0442\u043e\u043c \u0441 \u0442\u0440\u0443\u0434\u043e\u043c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442. \u0413\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u043e\u0442\u043b\u0430\u0434\u0438\u0442\u044c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0447\u0435\u043c \u043f\u043e\u0442\u043e\u043c \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441\u0443, \u043f\u043e\u0447\u0435\u043c\u0443 \u0441\u0435\u0440\u0432\u0438\u0441 \u0432\u0434\u0440\u0443\u0433 \u043b\u0451\u0433.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u0432\u0442\u0440\u0430 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0437\u043a\u043e \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043f\u043e\u0434 \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438\u043b\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0442\u043e\u0440\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u0441\u043b\u0435\u043f\u0443\u044e. \u041e\u043d\u0430 \u0437\u043d\u0430\u0435\u0442: \u0442\u0435\u0441\u0442\u044b \u043f\u043e\u043a\u0430\u0436\u0443\u0442, \u0433\u0434\u0435 \u0432\u0441\u0451 \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f, \u0438 \u044d\u0442\u043e \u0434\u0430\u0451\u0442 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e. \u0422\u0430\u043c, \u0433\u0434\u0435 \u0431\u0435\u0437 \u0442\u0435\u0441\u0442\u043e\u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f \u0442\u0440\u0430\u0442\u0438\u0442 \u043d\u0435\u0434\u0435\u043b\u0438 \u043d\u0430 \u0440\u0443\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0430\u0440\u044b \u043f\u0440\u043e\u0433\u043e\u043d\u043e\u0432 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430.<\/p>\n<p>\u041d\u0443 \u0438 \u043f\u0440\u043e \u043a\u0443\u043b\u044c\u0442\u0443\u0440\u0443. \u0412 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u0445, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u0432\u044b\u0447\u043a\u0430 \u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b, \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u044b \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0441\u043c\u0435\u043b\u044b\u0435 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u041d\u0435 \u0441\u0442\u0440\u0430\u0448\u043d\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433: \u0442\u0435\u0441\u0442\u044b \u043f\u0440\u0438\u043a\u0440\u043e\u044e\u0442 \u043e\u0442 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0439. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0437\u0440\u0435\u043b\u043e\u0439 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u043d\u0435\u0435.<\/p>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/companies\/netologyru\/articles\/909672\/\">Go<\/a> \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u2014 \u044d\u0442\u043e \u0447\u0435\u0441\u0442\u043d\u044b\u0439 \u0438 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442. \u0422\u0443\u0442 \u043d\u0435\u0442 \u043c\u0430\u0433\u0438\u0438, \u044f\u0437\u044b\u043a \u043f\u043e\u0434\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u0442 \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u043c\u0438 \u0438 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435\u043c. \u0414\u0430, \u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0443\u0442\u044c \u0434\u043e\u043b\u044c\u0448\u0435, \u0437\u0430\u0442\u043e \u043f\u043e\u0442\u043e\u043c \u043a\u043e\u0434 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u0435\u0435 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043f\u0440\u043e\u0449\u0435. \u0412\u043e\u0442 \u044d\u0442\u0430 \u0447\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u043e\u043c \u0437\u0440\u0435\u043b\u043e\u0433\u043e \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430.<\/p>\n<p>\u041a\u0430\u043a\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u0438\u0451\u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435:<\/p>\n<ul>\n<li>\n<p><strong>\u041e\u0434\u0438\u043d \u0442\u0435\u0441\u0442 = \u043e\u0434\u043d\u0430 \u0431\u0430\u0437\u0430.<\/strong> \u0412 CI \u044d\u0442\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u043d\u043e \u043d\u0430\u0434\u0451\u0436\u043d\u0435\u0435. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u0441\u0442\u0430\u043c\u0438: \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0441\u0432\u043e\u0451\u043c \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438, \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0443\u044e\u0442, \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c. \u0412\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u044e, \u0447\u0442\u043e \u043e\u0434\u0438\u043d \u0443\u043f\u0430\u0432\u0448\u0438\u0439 \u0442\u0435\u0441\u0442 \u043d\u0435 \u0437\u0430\u0440\u0430\u0437\u0438\u0442 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435. \u0414\u0430, \u0437\u0430 \u044d\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043b\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432, \u043d\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u044d\u0442\u0430 \u0446\u0435\u043d\u0430 \u043a\u0443\u0434\u0430 \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0438\u0445 \u043f\u0430\u0434\u0435\u043d\u0438\u0439. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u0435\u0441\u0442\u044b \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u043c\u0438 \u0432 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435. \u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 <code>t.Parallel()<\/code>, \u0442\u043e \u0431\u0435\u0437 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 \u044d\u0442\u043e \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0433\u043e\u043d\u043a\u0430\u043c \u0438 \u0433\u0440\u044f\u0437\u043d\u043e\u043c\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e. \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0431\u0430\u0437\u0430 \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0432 \u043a\u043e\u0440\u043d\u0435: \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a, \u0441\u043b\u043e\u0432\u043d\u043e \u043e\u043d \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439.<\/p>\n<\/li>\n<li>\n<p><strong>\u0422\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0441 \u043e\u0442\u043a\u0430\u0442\u0430\u043c\u0438.<\/strong> \u0415\u0441\u043b\u0438 \u043f\u043e \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0431\u0430\u0437\u0443 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442, \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e \u043d\u0430\u0434\u0451\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u2014 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0442\u0435\u0441\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u0435\u043b\u0430\u0442\u044c rollback. \u042d\u0442\u043e \u0434\u0435\u0448\u0451\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u0442\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435: \u0431\u0430\u0437\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0442\u0435\u0441\u0442 \u0443\u043f\u0430\u043b \u043f\u043e\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435, \u043e\u0442\u043a\u0430\u0442 \u0432\u0441\u0451 \u043f\u043e\u0434\u0447\u0438\u0441\u0442\u0438\u0442.<\/p>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0443\u0434\u043e\u0431\u0435\u043d \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u043f\u0438\u0448\u0443\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u0410 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438\u043b\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0441\u0442\u044b\u043b\u0438 \u0441 <code>truncate<\/code>: \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0440\u0435\u0448\u0430\u0435\u0442 \u044d\u0442\u043e \u0437\u0430 \u0432\u0430\u0441.<\/p>\n<\/li>\n<li>\n<p><code><strong>Eventually<\/strong><\/code><strong> \u0432\u043c\u0435\u0441\u0442\u043e <\/strong><code><strong>sleep<\/strong><\/code><strong>.<\/strong> \u0416\u0451\u0441\u0442\u043a\u0438\u0435 <code>sleep<\/code> \u2014 \u0432\u0440\u0430\u0433\u0438 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u041e\u043d\u0438 \u0438\u043b\u0438 \u0442\u0440\u0430\u0442\u044f\u0442 \u0432\u0440\u0435\u043c\u044f \u0437\u0440\u044f, \u0438\u043b\u0438 \u043d\u0435 \u0443\u0441\u043f\u0435\u0432\u0430\u044e\u0442 \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438 \u0432\u0430\u043b\u044f\u0442 \u0442\u0435\u0441\u0442. \u0413\u043e\u0440\u0430\u0437\u0434\u043e \u043d\u0430\u0434\u0451\u0436\u043d\u0435\u0435 \u043a\u0440\u0443\u0442\u0438\u0442\u044c\u0441\u044f \u0432 \u0446\u0438\u043a\u043b\u0435 \u0434\u043e \u0442\u0430\u0439\u043c-\u0430\u0443\u0442\u0430 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435. \u0422\u0430\u043a \u0442\u0435\u0441\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u0430 \u0435\u0441\u043b\u0438 \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u2014 \u043f\u0430\u0434\u0430\u0435\u0442 \u0447\u0435\u0441\u0442\u043d\u043e.<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0430\u0448\u0438 \u0442\u0435\u0441\u0442\u044b \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0435\u0435. \u041e\u043d\u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u044e\u0442 \u0431\u044b\u0442\u044c \u043b\u043e\u0442\u0435\u0440\u0435\u0435\u0439 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u043e\u0442\u0440\u0430\u0436\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u042d\u0442\u043e\u0442 \u043f\u0440\u0438\u0451\u043c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u0435\u043d \u0434\u043b\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 Kafka, Redis Pub\/Sub \u0438\u043b\u0438 \u0432\u0435\u0431\u0445\u0443\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p><code><strong>t.Cleanup()<\/strong><\/code><strong> \u0438 <\/strong><code><strong>defer<\/strong><\/code><strong>.<\/strong> \u0412 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e: \u0431\u0430\u0437\u044b, \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b, \u0432\u0440\u0435\u0301\u043c\u0435\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. \u0415\u0441\u043b\u0438 \u0438\u0445 \u043d\u0435 \u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e, \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0437\u0430\u0440\u0430\u0441\u0442\u0430\u0435\u0442 \u043c\u0443\u0441\u043e\u0440\u043e\u043c \u0438 \u0442\u0435\u0441\u0442\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u043f\u0430\u0434\u0430\u0442\u044c \u0443\u0436\u0435 \u043f\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>defer<\/code> \u0438 <code>t.Cleanup()<\/code> \u0440\u0435\u0448\u0430\u0435\u0442 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443: \u0432\u0441\u0451, \u0447\u0442\u043e \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438, \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u043e \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u043f\u0430\u043d\u0438\u043a\u0435 \u0438\u043b\u0438 \u0444\u0435\u0439\u043b\u0435.<\/p>\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u0430\u0451\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u0447\u0442\u043e \u0442\u0435\u0441\u0442\u044b \u043d\u0435 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u0433\u0440\u044f\u0437\u043d\u044b\u0445 \u0441\u043b\u0435\u0434\u043e\u0432. \u041d\u0430 CI \u044d\u0442\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e: \u0438\u043d\u0430\u0447\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u0438 \u0411\u0414 \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0438 \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439. \u0410 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u043d\u0435\u0440\u0432\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0443\u0431\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u043e\u043d\u0430.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0441\u0442\u0438, \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0439\u0442\u0438 \u0438\u0437 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0439 \u0437\u043e\u043d\u044b \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0448\u0430\u0433 \u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u0430\u043c. \u041c\u043e\u0436\u043d\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u0432\u043e\u0435, \u043d\u0430\u0447\u0430\u0432 \u0441 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0445 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>\u0437\u0430\u043f\u0438\u0441\u0438 \u043c\u0430\u0441\u0442\u0435\u0440-\u043a\u043b\u0430\u0441\u0441\u0430 \u00ab<a href=\"https:\/\/netology.ru\/free-lessons\/ai-protiv-spama?utm_source=habr&amp;utm_medium=externalblog&amp;utm_campaign=bhe_ai-protiv-spama_oz_habr_brand_article-16092025_media\">\u0418\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442 \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435<\/a>\u00bb;<\/p>\n<\/li>\n<li>\n<p>\u0433\u0430\u0439\u0434\u0430 \u00ab<a href=\"https:\/\/netology.ru\/programs\/mantra?utm_source=habr&amp;utm_medium=externalblog&amp;utm_campaign=blsh_mntr_guide_habr_brand_article-16092025_media\">\u0418\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u043e \u0441\u0430\u043c\u043e\u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>\u00bb;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u043f\u0438\u0441\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0439 \u0432\u0441\u0442\u0440\u0435\u0447\u0438 \u00ab<a href=\"https:\/\/netology.ru\/free-lessons\/oz_iot_ustrojstva?utm_source=habr&amp;utm_medium=externalblog&amp;utm_campaign=bhe_oz_iot_ustrojstva_oz_habr_brand_article-16092025_media\">\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c: \u043a\u0430\u043a \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043a\u0430\u0440\u044c\u0435\u0440\u0443 \u0432 \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u043c \u0431\u0443\u0434\u0443\u0449\u0435\u043c<\/a>\u00bb \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 \u0423\u0440\u0424\u0423;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/netology.ru\/programs\/airecommendations?utm_source=habr&amp;utm_medium=externalblog&amp;utm_campaign=activ_airecommendations_bou_habr_brand_article-16092025_media\">\u044d\u043a\u0441\u043f\u0440\u0435\u0441\u0441-\u043a\u043e\u043d\u0441\u0443\u043b\u044c\u0442\u0430\u0446\u0438\u0438<\/a> \u043f\u043e \u0432\u044b\u0431\u043e\u0440\u0443 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u0438 \u0432 IT.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u0430\u0442\u044c \u0432\u043e\u0441\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u043c \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0431\u00f3\u043b\u044c\u0448\u0438\u0435 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u044b \u0432 \u043a\u0430\u0440\u044c\u0435\u0440\u0435 \u0441 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c:<\/p>\n<ul>\n<li>\n<p>\u043d\u0430 \u043a\u0443\u0440\u0441\u0435 \u00ab<a href=\"https:\/\/netology.ru\/programs\/golpro?utm_source=habr&amp;utm_medium=externalblog&amp;utm_campaign=re_it_golpro_ou_habr_brand_article-16092025_media\">Go-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a: \u043a\u0443\u0440\u0441 \u0434\u043b\u044f IT-\u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u0432<\/a>\u00bb \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439 \u0442\u0440\u0443\u0434\u043e\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430 \u043a\u0443\u0440\u0441\u0435 \u00ab<a href=\"https:\/\/netology.ru\/programs\/devsecops?utm_source=habr&amp;utm_medium=externalblog&amp;utm_campaign=bhe_bheldso_ou_habr_brand_article-16092025_media\">DevSecOps: \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/a>\u00bb \u0441 \u041d\u0418\u0423 \u0412\u0428\u042d;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0434\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u0432 \u00ab<a href=\"https:\/\/netology.ru\/programs\/devops?utm_source=habr&amp;utm_medium=externalblog&amp;utm_campaign=re_it_shdevops_ou_habr_brand_article-16092025_media\">DevOps-\u0438\u043d\u0436\u0435\u043d\u0435\u0440<\/a>\u00bb \u0441 Yandex Cloud;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u043c \u043a\u0443\u0440\u0441\u0435 \u00ab<a href=\"https:\/\/netology.ru\/programs\/developer1c_ultimate?utm_source=habr&amp;utm_medium=externalblog&amp;utm_campaign=re_it_onecmid_ou_habr_brand_article-16092025_media\">1C\u2011\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442<\/a>\u00bb \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439 \u0442\u0440\u0443\u0434\u043e\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430.<\/p>\n<\/li>\n<\/ul>\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\/947796\/\">https:\/\/habr.com\/ru\/articles\/947796\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u0413\u043e\u043b\u0443\u0431\u044c, \u0438 \u044f \u043f\u0438\u0448\u0443 \u043d\u0430 Go \u0443\u0436\u0435 7 \u043b\u0435\u0442. \u041a\u043e\u0433\u0434\u0430 \u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u043b, \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u044b, \u0441\u0431\u043e\u0440\u043a\u0430 \u0437\u0435\u043b\u0451\u043d\u0430\u044f \u2014 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u043b\u0438\u0437\u0438\u0442\u044c. \u041d\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0436\u0435 \u0431\u043e\u0435\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u044d\u0442\u043e \u0438\u043b\u043b\u044e\u0437\u0438\u044f. \u0412 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435 \u0432\u0441\u0451 \u043f\u0430\u0434\u0430\u0435\u0442, \u0445\u043e\u0442\u044f \u044e\u043d\u0438\u0442\u044b \u0441\u0438\u044f\u044e\u0442 \u0437\u0435\u043b\u0451\u043d\u044b\u043c. \u041f\u043e\u0447\u0435\u043c\u0443? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u2014 \u044d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0434, \u043d\u043e \u0438 PostgreSQL, Redis, Kafka, \u0432\u043d\u0435\u0448\u043d\u0438\u0435 API. \u0414\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0447\u0435\u0440\u0435\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u0438 \u043b\u044e\u0431\u0430\u044f \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u043b\u043e\u043c\u0430\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u042e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043b\u043e\u0432\u044f\u0442. \u0422\u0443\u0442 \u043d\u0443\u0436\u043d\u044b \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435.\u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u0413\u043e\u043b\u0443\u0431\u044c\u0420\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u0433\u0440\u0443\u043f\u043f\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432 \u0421\u0438\u043c\u0430-\u043b\u0435\u043d\u0434\u0435, \u0441\u043e\u0430\u0432\u0442\u043e\u0440 \u043a\u0443\u0440\u0441\u0430 \u043f\u043e Golang \u0432 \u041d\u0435\u0442\u043e\u043b\u043e\u0433\u0438\u0438\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u0440\u0435\u0434\u043a\u043e \u043f\u0438\u0448\u0443\u0442 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u041c\u043d\u043e\u0433\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442 \u0438\u0445 \u043d\u0430 \u043f\u043e\u0442\u043e\u043c, \u0441\u0447\u0438\u0442\u0430\u044f \u043b\u0438\u0448\u043d\u0438\u043c\u0438 \u0437\u0430\u0442\u0440\u0430\u0442\u0430\u043c\u0438. \u041d\u0430 \u0434\u0435\u043b\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d\u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u043a\u0430\u043a \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0440\u0430\u0437\u0433\u043e\u0432\u0430\u0440\u0438\u0432\u0430\u044e\u0442 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c, \u043a\u0430\u043a \u0432\u0435\u0434\u0443\u0442 \u0441\u0435\u0431\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u0438 \u0432\u044b\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443. \u0418 \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u043d\u0435\u0442, \u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0437\u0430\u043b\u043e\u0436\u043d\u0438\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0441\u0442\u0435\u0439: \u0447\u0442\u043e-\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435, \u043d\u043e \u043f\u0430\u0434\u0430\u0435\u0442 \u0432 CI \u0438\u043b\u0438, \u0447\u0442\u043e \u0445\u0443\u0436\u0435, \u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430.\u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043e\u0431 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u0432 Go \u2014 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e \u0442\u0435\u043e\u0440\u0438\u044e, \u0430 \u043f\u0440\u043e \u0432\u044b\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041e\u043d\u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0443\u0431\u0440\u0430\u0442\u044c \u0444\u043b\u0430\u043a\u0438, \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u0445\u0430\u043e\u0441 \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c CI \u0432 \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u0430 \u043d\u0435 \u043b\u043e\u0442\u0435\u0440\u0435\u044e.\u041f\u043e\u0447\u0435\u043c\u0443 Go \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432\u0412 Go \u043d\u0435\u0442 \u043c\u0430\u0433\u0438\u0438 \u0432\u0440\u043e\u0434\u0435 @Transactional \u0438\u043b\u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0444\u0438\u043a\u0441\u0442\u0443\u0440, \u043a\u0430\u043a \u0432 Java \u0438\u043b\u0438 Python. \u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b, \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c \u0440\u0443\u043a\u0430\u043c\u0438. \u042f\u0437\u044b\u043a \u0434\u0430\u0451\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u044b\u0439, \u043d\u043e \u043c\u043e\u0449\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 \u2014 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 testing \u0438 \u0443\u0434\u043e\u0431\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438. \u0412\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u043a\u0440\u0443\u0433 \u044d\u0442\u043e\u0433\u043e. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043a\u0440\u044b\u0432\u0430\u044e\u0442 \u0434\u0435\u0442\u0430\u043b\u0438 \u0437\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438 \u0438\u043b\u0438 DSL, \u0432 Go \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441: \u0433\u0434\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f PostgreSQL, \u043a\u0430\u043a \u043d\u0430\u043a\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0447\u0438\u0449\u0430\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u0430 \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u0441\u0442\u0430\u043c\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u043e\u0439, \u043d\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u0430\u044f \u044f\u0432\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u0435\u0441\u0442\u044b \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u043c\u0438, \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u043c\u0438 \u0438 \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u043c\u0438. \u0415\u0441\u043b\u0438 \u0431\u0430\u0437\u0430 \u043d\u0435 \u0433\u043e\u0442\u043e\u0432\u0430, \u044d\u0442\u043e \u0432\u0438\u0434\u043d\u043e. \u0415\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0441\u044c \u2014 \u0442\u043e\u0436\u0435 \u0432\u0438\u0434\u043d\u043e.\u0415\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043b\u044e\u0441\u044b:\u0415\u0434\u0438\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430. \u0412\u0441\u0451 \u0433\u043e\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 go test, \u0431\u0435\u0437 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0440\u0430\u043d\u043d\u0435\u0440\u043e\u0432 \u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0441\u043b\u043e\u0451\u0432.\u041f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e t.Parallel() \u043b\u0435\u0433\u043a\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b, \u0435\u0441\u043b\u0438 \u043a\u0430\u0436\u0434\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0438\u0437\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043e.\u0413\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0412\u044b \u0441\u0430\u043c\u0438 \u0440\u0435\u0448\u0430\u0435\u0442\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438 dockertest, Testcontainers \u0438\u043b\u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 mock-\u0441\u0435\u0440\u0432\u0435\u0440\u044b. \u041d\u0435\u0442 \u0436\u0451\u0441\u0442\u043a\u043e\u0439 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0443.\u0427\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c \u0432\u0434\u043e\u043b\u0433\u0443\u044e. \u0422\u0435\u0441\u0442\u044b \u0432 Go \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u0434: \u0431\u0435\u0437 \u0441\u043a\u0440\u044b\u0442\u044b\u0445 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0438 \u0445\u0438\u0442\u0440\u044b\u0445 \u043e\u0431\u0451\u0440\u0442\u043e\u043a. \u041b\u044e\u0431\u043e\u0439 \u043d\u043e\u0432\u0438\u0447\u043e\u043a \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \u0438 \u0441\u0440\u0430\u0437\u0443 \u0432\u0438\u0434\u0438\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.\u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b \u043d\u0430 Go \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0436\u0438\u0432\u0443\u0442 \u0434\u043e\u043b\u044c\u0448\u0435 \u0438 \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u0435\u0435, \u0447\u0435\u043c \u0432 \u044f\u0437\u044b\u043a\u0430\u0445 \u0432\u0440\u043e\u0434\u0435 Python, JavaScript \u0438\u043b\u0438 Ruby, \u0433\u0434\u0435 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u043e\u0431\u044b\u0447\u043d\u043e \u0435\u0441\u0442\u044c \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0438 \u043e\u0431\u0451\u0440\u0442\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u00ab\u0434\u0435\u043b\u0430\u044e\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044e \u0443\u0434\u043e\u0431\u043d\u0435\u0435\u00bb. \u041d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u0432 \u043d\u0438\u0445 \u0431\u044b\u0441\u0442\u0440\u0435\u0435: \u043c\u043d\u043e\u0433\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043c\u043d\u043e\u0433\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0439. \u041d\u043e \u043c\u0438\u043d\u0443\u0441 \u2014 \u0442\u0430\u043a\u0438\u0435 \u0442\u0435\u0441\u0442\u044b \u043f\u043e\u0442\u043e\u043c \u0447\u0430\u0449\u0435 \u043b\u043e\u043c\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u0430\u043f\u0433\u0440\u0435\u0439\u0434\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439, \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043c\u043e\u043a\u043e\u0432 \u0438 \u043a\u043e\u0441\u0442\u044b\u043b\u0435\u0439. \u0422\u0430\u043a \u0447\u0442\u043e \u0441 Go \u0432\u044b \u043f\u043b\u0430\u0442\u0438\u0442\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435, \u043d\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u0435 \u0435\u0433\u043e \u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c.\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0431\u043e\u043b\u044c \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u2014 \u0444\u043b\u0430\u043a\u0438\u0424\u043b\u0430\u043a\u0438 \u0443\u0431\u0438\u0432\u0430\u044e\u0442 \u0434\u043e\u0432\u0435\u0440\u0438\u0435 \u043a \u0442\u0435\u0441\u0442\u0430\u043c. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435: \u0431\u0438\u043b\u0434 \u043f\u0430\u0434\u0430\u0435\u0442 \u043d\u0435 \u0438\u0437-\u0437\u0430 \u0431\u0430\u0433\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0431\u0430\u0437\u0430 \u043d\u0435 \u0443\u0441\u043f\u0435\u043b\u0430 \u043f\u043e\u0434\u043d\u044f\u0442\u044c\u0441\u044f \u0438\u043b\u0438 \u0442\u0435\u0441\u0442\u044b \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u043b\u0438\u0441\u044c \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0432\u0438\u0434\u044f\u0442 \u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0438 \u0443\u0436\u0435 \u043d\u0435 \u0434\u0443\u043c\u0430\u044e\u0442 \u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435 \u0432 \u0441\u0432\u043e\u0451\u043c \u043a\u043e\u0434\u0435 \u2014 \u0441\u043a\u043e\u0440\u0435\u0435, \u0440\u0435\u0448\u0430\u044e\u0442, \u0447\u0442\u043e CI \u043e\u043f\u044f\u0442\u044c \u0448\u0430\u043b\u0438\u0442. \u041f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0432\u044b\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u043c\u043c\u0443\u043d\u0438\u0442\u0435\u0442 \u043a \u043a\u0440\u0430\u0441\u043d\u043e\u043c\u0443: \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0442\u043e\u043d\u0443\u0442 \u0432 \u0448\u0443\u043c\u0435 \u0438 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0431\u0430\u0433 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435\u0434\u0435\u043b\u044e \u0432\u0438\u0441\u0435\u0442\u044c \u0432 \u043c\u0430\u0441\u0442\u0435\u0440\u0435, \u043f\u043e\u043a\u0430 \u0432\u0441\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u0434\u0435\u043b\u043e \u0432 \u0442\u0435\u0441\u0442\u0430\u0445.\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0444\u043b\u0430\u043a\u0438 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0431\u044c\u044e\u0442 \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0412\u0440\u0435\u043c\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u0440\u0430\u0441\u0442\u0451\u0442 \u0437\u0430 \u0441\u0447\u0451\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u043e\u043d\u043e\u0432, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0442\u0440\u0430\u0442\u044f\u0442 \u0447\u0430\u0441\u044b \u043d\u0430 \u0432\u044b\u044f\u0441\u043d\u0435\u043d\u0438\u0435, \u00ab\u043f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u043d\u043e \u0443\u043f\u0430\u043b\u043e\u00bb, \u0430 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0441\u043e\u043c\u043d\u0435\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0430\u0434\u0451\u0436\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0418\u0442\u043e\u0433 \u2014 \u0442\u0435\u0441\u0442\u044b \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u044e\u0442 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0437\u0430\u0449\u0438\u0442\u0430 \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0431\u0443\u0437\u0443.\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u0435 \u0444\u043b\u0430\u043a\u0438 \u0440\u0430\u0437\u0440\u0443\u0448\u0430\u044e\u0442 \u043a\u0443\u043b\u044c\u0442\u0443\u0440\u0443 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435. \u0415\u0441\u043b\u0438 \u0442\u0435\u0441\u0442\u044b \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u043d\u0435\u043d\u0430\u0434\u0451\u0436\u043d\u044b\u043c\u0438, \u0442\u043e \u0438 \u043c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043f\u0430\u0434\u0430\u0435\u0442. \u0410 \u0434\u0430\u043b\u044c\u0448\u0435 \u2014 \u043f\u0440\u044f\u043c\u043e\u0439 \u043f\u0443\u0442\u044c \u043a \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u0439\u043c\u0430\u0442\u044c \u0437\u0430\u0440\u0430\u043d\u0435\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441 \u0444\u043b\u0430\u043a\u0430\u043c\u0438 \u0431\u043e\u0440\u044e\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0440\u0430\u0434\u0438 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0442\u0435\u0441\u0442\u044b \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u0449\u0438\u0449\u0430\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442.\u0414\u0430\u043b\u0435\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u044b \u0444\u043b\u0430\u043a\u043e\u0432.1. \u0411\u0430\u0437\u0430 \u043d\u0435 \u0433\u043e\u0442\u043e\u0432\u0430\u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0441\u044f, \u043d\u043e PostgreSQL \u0435\u0449\u0451 \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f. \u0420\u0435\u0448\u0435\u043d\u0438\u0435: \u043d\u0435 time.Sleep, \u0430 \u0446\u0438\u043a\u043b \u0441 Ping + retry. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c time.Sleep(10 * time.Second), \u0442\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u0441\u0451 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u2014 \u043f\u0430\u0434\u0430\u0442\u044c. \u0411\u0430\u0437\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0438 \u0437\u0430 2 \u0441\u0435\u043a\u0443\u043d\u0434\u044b, \u0438 \u0437\u0430 20, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u0436\u0435\u043b\u0435\u0437\u0430.func waitForPostgres(dsn string, timeout time.Duration) error {    deadline := time.Now().Add(timeout)    ticker := time.NewTicker(500 * time.Millisecond)    defer ticker.Stop()    var lastErr error    for range ticker.C {        if time.Now().After(deadline) {            break        }        db, err := sql.Open(&#171;postgres&#187;, dsn)        if err != nil {            lastErr = err            continue        }     ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)        pingErr := db.PingContext(ctx)        cancel()        _ = db.Close()        if pingErr == nil {            return nil        }        lastErr = pingErr    }    return fmt.Errorf(&#171;Postgres \u043d\u0435 \u043f\u043e\u0434\u043d\u044f\u043b\u0441\u044f \u0437\u0430 %s: %w&#187;, timeout, lastErr)}\u0424\u0443\u043d\u043a\u0446\u0438\u044f waitForPostgres \u0440\u0435\u0448\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443: \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u0438 PostgreSQL \u043a \u043f\u0440\u0438\u0451\u043c\u0443 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0430\u0439\u043c-\u0430\u0443\u0442\u0430.\u041e\u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0446\u0438\u043a\u043b \u0441 \u0442\u0438\u043a\u0435\u0440\u043e\u043c \u2014 \u043a\u0430\u0436\u0434\u044b\u0435 500 \u043c\u0441.\u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c PingContext \u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u0442\u0430\u0439\u043c-\u0430\u0443\u0442\u043e\u043c \u0432 2 \u0441\u0435\u043a\u0443\u043d\u0434\u044b.\u0415\u0441\u043b\u0438 \u0431\u0430\u0437\u0430 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u0440\u0430\u0437\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 nil.\u0415\u0441\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u0438\u0441\u0442\u0435\u043a\u043b\u043e, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u0441\u0431\u043e\u044f.\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 time.Sleep, \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u044c PostgreSQL \u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u043c \u0440\u043e\u0432\u043d\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0441\u0442\u0430\u043b \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d (\u0438\u043b\u0438 \u043a\u043e\u0433\u0434\u0430 \u0442\u0430\u0439\u043c-\u0430\u0443\u0442 \u0432\u044b\u0448\u0435\u043b).2. \u0413\u0440\u044f\u0437\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\u0412 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0435 \u0433\u0440\u044f\u0437\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0434\u0438\u043d \u0442\u0435\u0441\u0442 \u0441\u043e\u0437\u0434\u0430\u043b \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0437\u0430\u043a\u0430\u0437\u043e\u0432, \u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043e\u0436\u0438\u0434\u0430\u043b, \u0447\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439. \u0415\u0441\u043b\u0438 \u043e\u043d\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e, \u0432\u0442\u043e\u0440\u043e\u0439 \u0442\u0435\u0441\u0442 \u0442\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442, \u0442\u043e \u043f\u0430\u0434\u0430\u0435\u0442 \u2014 \u0432\u0441\u0451 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0443\u0441\u043f\u0435\u043b \u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u0443\u0436\u0435 \u0447\u0442\u043e-\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c. \u0418\u0437-\u0437\u0430 \u0442\u0430\u043a\u043e\u0439 \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0441\u0442\u0438 \u0442\u0435\u0441\u0442 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0444\u043b\u0435\u0439\u043a\u043e\u0432\u044b\u043c (flaky, \u0438\u043b\u0438 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u043c, \u0444\u043b\u0430\u043a\u0438-\u0442\u0435\u0441\u0442\u043e\u043c) \u0438 \u0434\u043e\u0432\u0435\u0440\u0438\u0435 \u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c \u0431\u044b\u0441\u0442\u0440\u043e \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f.\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0434\u0432\u0443\u043c\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u043c\u0438:\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439 \u0441 \u043e\u0442\u043a\u0430\u0442\u043e\u043c (rollback)\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430\u2022 \u041a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0432\u043e\u0435\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438.\u2022 \u0412 \u043a\u043e\u043d\u0446\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f ROLLBACK, \u0438 \u0431\u0430\u0437\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a \u0447\u0438\u0441\u0442\u043e\u043c\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044e.\u2022 \u041f\u043b\u044e\u0441: \u0431\u044b\u0441\u0442\u0440\u043e, \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u044b, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432.\u2022 \u041a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u043f\u0443\u0441\u0442\u0443\u044e \u0431\u0430\u0437\u0443, \u0447\u0430\u0441\u0442\u043e \u0447\u0435\u0440\u0435\u0437 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 Docker.\u2022 \u0413\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u0441\u0442\u0430\u043c\u0438.\u2022 \u041c\u0438\u043d\u0443\u0441: \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432.\u0412\u043e\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u043a\u0430\u0442\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430:func runInTx(t *testing.T, fn func(tx *sql.Tx)) {    t.Helper()    tx, err := db.Begin()    if err != nil {        t.Fatalf(&#171;\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0447\u0430\u0442\u044c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e: %v&#187;, err)    }    defer func() { _ = tx.Rollback() }()    fn(tx)}func TestCreateUser(t *testing.T) {    runInTx(t, func(tx *sql.Tx) {        _, err := tx.Exec(&#171;INSERT INTO users(name) VALUES($1)&#187;, &#171;Alice&#187;)        if err != nil {            t.Fatalf(&#171;insert: %v&#187;, err)        }        var count int        if err := tx.QueryRow(&#171;SELECT COUNT(*) FROM users&#187;).Scan(&amp;count); err != nil {            t.Fatalf(&#171;query: %v&#187;, err)        }        if count != 1 {            t.Errorf(&#171;\u041e\u0436\u0438\u0434\u0430\u043b\u0438 1 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 %d&#187;, count)        }    })}3. \u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0449\u0438\u043d\u0430\u041a\u043e\u0433\u0434\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u043e\u0439 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u2014 Kafka, Redis Pub\/Sub, RabbitMQ \u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435, \u2014 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e. \u041e\u0434\u0438\u043d \u0442\u0435\u0441\u0442 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u043d\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0438\u043b\u0438 \u0441\u043e\u0442\u043d\u0438 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u0440\u0430\u0437\u0443, \u0442\u0435\u0441\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0430\u0434\u0430\u0442\u044c, \u0445\u043e\u0442\u044f \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u042d\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f race condition \u0432 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u0430\u0445. \u041a\u0430\u043a \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c:\u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u00ab\u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441\u00bb, \u0441\u043a\u0430\u0437\u0430\u0442\u044c: \u00ab\u0434\u0430\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0432\u0440\u0435\u043c\u044f, \u043d\u043e \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 N \u0441\u0435\u043a\u0443\u043d\u0434\u00bb;\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e eventually, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 (cond) \u043a\u0430\u0436\u0434\u044b\u0435 200 \u043c\u0441 \u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0441\u0440\u0430\u0437\u0443, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0430 \u0432\u0435\u0440\u043d\u0451\u0442 true.\u0415\u0441\u043b\u0438 \u0437\u0430 \u043e\u0442\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0442\u0430\u043a \u0438 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u043e\u0441\u044c, \u0442\u0435\u0441\u0442 \u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439. \u041d\u0438\u0436\u0435 \u2014 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u0441 eventually:func eventually(t *testing.T, cond func() bool, timeout time.Duration) {    t.Helper()    ticker := time.NewTicker(200 * time.Millisecond)    defer ticker.Stop()    timeoutC := time.After(timeout)    for {        select {        case &lt;-ticker.C:            if cond() {                return            }        case &lt;-timeoutC:            t.Fatalf(&#171;\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u0437\u0430 %s&#187;, timeout)        }    }}func TestMessageDelivered(t *testing.T) {    sendMessage(&#171;hello&#187;)    eventually(t, func() bool {        msg, ok := tryReceiveMessage()        return ok &amp;&amp; msg == &#171;hello&#187;    }, 5*time.Second)}4. Shared state\u041a\u043e\u0433\u0434\u0430 \u0442\u0435\u0441\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0434\u043d\u0443 \u0411\u0414, \u043e\u0434\u0438\u043d \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 Kafka, \u043e\u0434\u0438\u043d Redis, \u2014 \u043e\u043d\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e \u0432\u043b\u0438\u044f\u0442\u044c \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430:\u0414\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0442\u0441\u044f. \u041e\u0434\u0438\u043d \u0442\u0435\u0441\u0442 \u0432\u0441\u0442\u0430\u0432\u0438\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f &#171;Alice&#187;, \u0434\u0440\u0443\u0433\u043e\u0439 \u043e\u0436\u0438\u0434\u0430\u043b \u043f\u0443\u0441\u0442\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u2014 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u0418\u043b\u0438 \u0434\u0432\u0430 \u0442\u0435\u0441\u0442\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c, \u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 duplicate key.\u0421\u0431\u043e\u0438 \u0438\u0437-\u0437\u0430 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0422\u0435\u0441\u0442\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e (go test -parallel), \u0438 \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u0434\u0440\u0443\u0433\u043e\u0439 \u0438\u0445 \u0447\u0438\u0442\u0430\u0435\u0442. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0444\u043b\u0435\u0439\u043a\u043e\u0432\u044b\u0435 \u0442\u0435\u0441\u0442\u044b: \u0438\u043d\u043e\u0433\u0434\u0430 \u0437\u0435\u043b\u0451\u043d\u044b\u0435, \u0438\u043d\u043e\u0433\u0434\u0430 \u043a\u0440\u0430\u0441\u043d\u044b\u0435.\u041a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u044b \u043f\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c. \u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0441\u0442\u043e\u0432 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0442\u043e\u043f\u0438\u043a Kafka \u0438\u043b\u0438 \u043e\u0434\u0438\u043d Redis-\u043a\u0430\u043d\u0430\u043b. \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0443\u0442\u0435\u043a\u0430\u044e\u0442 \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u0441\u0442\u0430\u043c\u0438, \u0438 \u0442\u0435\u0441\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u0447\u0443\u0436\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.\u041d\u0435\u043e\u0447\u0438\u0449\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u041e\u0434\u0438\u043d \u0442\u0435\u0441\u0442 \u0437\u0430\u0431\u044b\u043b \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043b\u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0439. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0442\u0435\u0441\u0442\u044b \u0441\u0442\u0430\u0440\u0442\u0443\u044e\u0442 \u043d\u0435 \u0441 \u043d\u0443\u043b\u044f, \u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u043c.\u0418\u0437\u043e\u043b\u044f\u0446\u0438\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u0435\u0441\u0442 \u0432\u0438\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u043e\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u043e\u0441\u0435\u0434\u0435\u0439. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u0435\u0441\u0442\u044b \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c\u044b\u043c\u0438, \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u043c\u0438 \u0438&#8230;<\/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-475460","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/475460","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=475460"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/475460\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=475460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=475460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=475460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}