{"id":363683,"date":"2024-05-21T02:01:21","date_gmt":"2024-05-21T02:01:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=363683"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=363683","title":{"rendered":"<span>\u0414\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 \u0432 go<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/be2\/6e4\/205\/be26e42052d21b59156264fc2ab67928.jpg\" width=\"1280\" height=\"731\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/be2\/6e4\/205\/be26e42052d21b59156264fc2ab67928.jpg\" data-blurred=\"true\"\/><\/figure>\n<p><em>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/em><\/p>\n<p>\u0414\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 (\u0438\u043b\u0438 generics) \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a Java, C#, \u0438 Rust, \u043d\u043e \u0434\u043b\u044f Go \u044d\u0442\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u043e\u0432\u0430\u044f \u0444\u0438\u0447\u0430, \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u0430\u044f \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 1.18.<\/p>\n<p>\u0414\u043e \u0432\u0435\u0440\u0441\u0438\u0438 1.18 Go \u0431\u044b\u043b \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0441\u0432\u043e\u0438\u043c \u0441\u0442\u0440\u043e\u0433\u0438\u043c \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c \u043a \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438. \u041e\u0434\u043d\u0430\u043a\u043e, \u0441 \u0440\u043e\u0441\u0442\u043e\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u0430\u043b\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u0435\u043d \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412\u0441\u0435 \u0432\u0435\u0447\u043d\u043e \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438, \u043a\u043e\u0433\u0434\u0430 \u0438\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0438 \u043f\u0443\u0441\u0442\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b.<\/p>\n<p>Go \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u044e \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u043b\u0433\u0438\u0445 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0439 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0439 \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 1.18. \u042d\u0442\u043e \u0431\u044b\u043b \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u043f\u0440\u043e\u0441\u044c\u0431\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430. + \u043a \u043a\u0430\u0440\u043c\u0435<\/p>\n<p>\u0414\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0441\u0442\u044b\u0439 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u043a\u043e\u0434. \u0412\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0435 \u043e\u0431\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0438 \u0437\u0430\u0442\u0435\u043c \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u0441 \u043b\u044e\u0431\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>\u041a\u0440\u0430\u0442\u043a\u043e \u043f\u0440\u043e\u0439\u0434\u0435\u043c\u0441\u044f \u043f\u043e \u0431\u0430\u0437\u0435:<\/p>\n<h4>\u0422\u0438\u043f\u044b \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/h4>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u043b\u044e\u0431\u043e\u0433\u043e \u0441\u043b\u0430\u0439\u0441\u0430. \u0411\u0435\u0437 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432 \u0432\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u043e \u0441 Type Parameters \u0432\u044b \u043f\u0438\u0448\u0435\u0442\u0435 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"go\">func First[T any](s []T) T {     return s[0] }<\/code><\/pre>\n<p><code>T<\/code> \u2014 \u044d\u0442\u043e type parameter. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0447\u0435\u043c \u0443\u0433\u043e\u0434\u043d\u043e: int, string, \u0432\u0430\u0448\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u0442\u0438\u043f\u043e\u043c, \u0447\u0435\u043c \u0443\u0433\u043e\u0434\u043d\u043e. \u0410 <code>any<\/code> \u2014 \u044d\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043b\u044e\u0431\u044b\u043c \u0442\u0438\u043f\u043e\u043c<\/p>\n<h4>Type set<\/h4>\n<p>Type Sets (\u0432 Go \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u043d\u0438\u0436\u0435 1.18 \u043d\u0430\u0437\u044b\u0432\u0430\u043b\u0438\u0441\u044c Contracts) \u2014 \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043d\u0430 \u0442\u0438\u043f\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0441 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u043c\u0438. <\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u044b \u043f\u0438\u0448\u0435\u0442\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438. \u0411\u0435\u0437 Contracts \u0432\u044b \u0431\u044b\u043b\u0438 \u0431\u044b \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u044b \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0434\u043e\u0431\u0440\u043e\u0441\u043e\u0432\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 (\u0438 \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u043d\u0430\u0434\u0435\u0436\u043d\u043e). \u041d\u043e \u0441 Contracts \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0430\u0448\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0442\u0438\u043f\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"go\">type Number interface {     int | float64 \/\/ \u0442\u043e\u043b\u044c\u043a\u043e \u0446\u0435\u043b\u044b\u0435 \u0438 \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430. }  func Sum[T Number](a, b T) T {     return a + b }<\/code><\/pre>\n<h4>Type inference  <\/h4>\n<p>Type inference \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0443\u0433\u0430\u0434\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u044b \u0438\u043c\u0435\u0435\u0442\u0435 \u0432 \u0432\u0438\u0434\u0443, \u043d\u0435 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0432\u0430\u0441 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u043c\u0435\u043b\u043e\u0447\u044c. \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u043c\u0438, Go \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u043d\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0442\u0438\u043f\u044b \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ Generic \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043b\u044e\u0431\u044b\u043c \u0442\u0438\u043f\u043e\u043c. func Print[T any](s T) {     fmt.Println(s) }  func main() {     \/\/ Go \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0442\u0438\u043f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 T \u043a\u0430\u043a int.     Print(123)      \/\/ Go \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0442\u0438\u043f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 T \u043a\u0430\u043a string.     Print(\"Hello, Generics!\") }<\/code><\/pre>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 Go \u043c\u043e\u0436\u0435\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c: &#171;\u0423 \u0442\u0435\u0431\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432, \u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u0432\u044b\u0431\u0440\u0430\u0442\u044c.&#187; \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430, \u0438\u043b\u0438 \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u0448 \u043a\u043e\u0434 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0433\u0430\u0434\u043e\u0447\u0435\u043d, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0443\u043c\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432 \u0441\u0442\u0443\u043f\u043e\u0440\u0435:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  func Merge[T any, U any](first T, second U) {     fmt.Println(first, second) }  func main() {     \/\/ \u044f\u0432\u043d\u043e\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0442\u0430\u043a \u043a\u0430\u043a Go \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0438\u0445     Merge[int, string](42, \"The answer is\") }<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 Go \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0442\u0438\u043f, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u0430\u0442\u044c \u0435\u043c\u0443 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0443, \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0432 \u0442\u0438\u043f \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u0430\u043a \u0432 11 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 \u043a\u043e\u0434\u0430 \u0432\u044b\u0448\u0435.<\/p>\n<p>\u0412\u0441\u0435 \u044d\u0442\u043e \u0437\u0432\u0443\u0447\u0438\u0442 \u043a\u043b\u0430\u0441\u0441\u043d\u043e, \u043d\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 \u2014 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0430\u0445\u0430\u0440, \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430.  \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043b\u0438 \u0442\u0438\u043f\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043b\u0438 \u0442\u0438\u043f\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<h2>\u0414\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 \u0432 Go<\/h2>\n<h4>Constraints \u0438 type sets<\/h4>\n<p>Constraints, \u0438\u043b\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 &#8212; \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0432 \u043d\u0430\u0448\u0438\u0445 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u0445. <\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438. \u0411\u0435\u0437 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432, \u0432\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f <code>int<\/code>, <code>float64<\/code>, \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u041d\u043e \u0441 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u043c\u0438 \u0438 constraints, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0430\u0445\u0443. \u0412\u043e\u0442 \u043a\u0430\u043a:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043d\u0430\u0448 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 constraint. type Number interface {     int | float64 \/\/ \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c int \u0438\u043b\u0438 float64. }  \/\/ UniversalAdd \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0432 Number. func UniversalAdd[T Number](a, b T) T {     return a + b }  func main() {     \/\/ \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 int.     fmt.Println(UniversalAdd[int](1, 2))      \/\/ \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 float64.     fmt.Println(UniversalAdd[float64](1.5, 2.3)) }<\/code><\/pre>\n<p> <code>UniversalAdd<\/code> &#8212; \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0432 <code>Number<\/code>. \u042d\u0442\u043e \u043e\u0447. \u0443\u0434\u043e\u0431\u043d\u043e. \u041e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<p>\u0412\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h4>comparable, any<\/h4>\n<p><code>comparable<\/code> &#8212; \u044d\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c, \u0447\u0442\u043e \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 <code>==<\/code> \u0438 <code>!=<\/code>:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ Distinct \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u044d\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u0441\u043b\u0430\u0439\u0441\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b func Distinct[T comparable](list []T) []T {     unique := make(map[T]bool)     var result []T     for _, item := range list {         if !unique[item] {             unique[item] = true             result = append(result, item)         }     }     return result }  func main() {     \/\/ \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043b\u044e\u0431\u044b\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u043c\u044b\u043c \u0442\u0438\u043f\u043e\u043c     fmt.Println(Distinct([]int{1, 2, 2, 3, 4, 4, 4, 5}))     fmt.Println(Distinct([]string{\"\u043a\u043e\u0442\u0438\u043a\", \"\u043a\u043e\u0448\u0435\u0447\u043a\u0430\", \"\u043a\u043e\u0442\", \"\u043a\u043e\u0448\u043a\u0430\"})) }<\/code><\/pre>\n<p><code>Distinct<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>comparable<\/code> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u043e\u0432 \u0438\u0437 \u0441\u043b\u0430\u0439\u0441\u0430. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a <code>any<\/code>. \u042d\u0442\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432 Go, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043f\u043e \u0441\u0443\u0442\u0438, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0447\u0435\u043c \u0443\u0433\u043e\u0434\u043d\u043e:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ PrintAny \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043b\u0430\u0439\u0441 \u043b\u044e\u0431\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0438\u0445. func PrintAny(items []any) {     for _, item := range items {         fmt.Println(item)     } }  func main() {     \/\/ \u041c\u043e\u0436\u0435\u043c \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445!     PrintAny([]any{1, \"apple\", true, 3.14}) }<\/code><\/pre>\n<p><code>PrintAny<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043b\u0430\u0439\u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0438 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0438\u0445. <\/p>\n<h4>\u0423\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h4>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043a\u043b\u0430\u0441\u0441\u0438\u043a\u0438 &#8212; \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u043c\u0435\u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, <code>Swap<\/code>. \u0411\u0435\u0437 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0441 \u043d\u0438\u043c\u0438 \u0432\u0441\u0435 \u0433\u043e\u0440\u0430\u0437\u0434\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ Swap \u043c\u0435\u043d\u044f\u0435\u0442 \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430. func Swap[T any](a, b *T) {     *a, *b = *b, *a }  func main() {     x := 1     y := 2     Swap(&amp;x, &amp;y)     fmt.Println(x, y) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: 1 2      s1 := \"Hello\"     s2 := \"Habr\"     Swap(&amp;s1, &amp;s2)     fmt.Println(s1, s2) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: Hello Habr }<\/code><\/pre>\n<p><code>Swap<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>any<\/code>, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043b\u044e\u0431\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u043e \u043a\u0430\u043a \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u043a \u043c\u0438\u0440\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445!<\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0447\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435 &#8212; \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u044d\u0448\u0430:<\/h3>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ Cache - \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043a\u044d\u0448\u0430. \/\/ T - \u0442\u0438\u043f \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. type Cache[T any] struct {     store map[string]T }  \/\/ NewCache \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 Cache. func NewCache[T any]() *Cache[T] {     return &amp;Cache[T]{store: make(map[string]T)} }  \/\/ Set \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043a\u044d\u0448. func (c *Cache[T]) Set(key string, value T) {     c.store[key] = value }  \/\/ Get \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u043a\u044d\u0448\u0430. func (c *Cache[T]) Get(key string) (T, bool) {     val, found := c.store[key]     return val, found }  func main() {     \/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u044d\u0448 \u0434\u043b\u044f int.     intCache := NewCache[int]()     intCache.Set(\"key1\", 10)     fmt.Println(intCache.Get(\"key1\")) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: 10 true      \/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u044d\u0448 \u0434\u043b\u044f string.     stringCache := NewCache[string]()     stringCache.Set(\"hello\", \"world\")     fmt.Println(stringCache.Get(\"hello\")) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: world true }<\/code><\/pre>\n<p><code>Cache<\/code> &#8212; \u044d\u0442\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u044d\u0448 \u0434\u043b\u044f \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b, \u0441\u0442\u0440\u043e\u043a, \u0438\u043b\u0438 \u0447\u0435\u0433\u043e \u0443\u0433\u043e\u0434\u043d\u043e, \u0447\u0442\u043e \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435.<\/p>\n<h2>\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435<\/h2>\n<h4>\u0421\u043b\u0430\u0439\u0441\u044b: <\/h4>\n<p>\u0421\u043b\u0430\u0439\u0441\u044b \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0441\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u0441\u0436\u0438\u043c\u0430\u0442\u044c\u0441\u044f, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044f \u043d\u0430 \u0441\u0435\u0431\u044f \u0432\u0441\u0435, \u0447\u0442\u043e \u0432\u044b \u0438\u043c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u0435. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u043b\u0430\u0439\u0441\u0430\u043c\u0438 \u043b\u044e\u0431\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ Filter \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043b\u0430\u0439\u0441 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f \u043d\u043e\u0432\u044b\u0439 \u0441\u043b\u0430\u0439\u0441 \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0438\u043c\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044e. func Filter[T any](slice []T, predicate func(T) bool) []T {     var result []T     for _, v := range slice {         if predicate(v) {             result = append(result, v)         }     }     return result }  func main() {     \/\/ \u0424\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u043c \u0441\u043b\u0430\u0439\u0441 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b.     ints := []int{1, 2, 3, 4, 5}     even := Filter(ints, func(n int) bool { return n%2 == 0 })     fmt.Println(even) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: [2 4]      \/\/ \u0424\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u043c \u0441\u043b\u0430\u0439\u0441 \u0441\u0442\u0440\u043e\u043a.     strings := []string{\"apple\", \"banana\", \"cherry\"}     withA := Filter(strings, func(s string) bool { return s[0] == 'a' })     fmt.Println(withA) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: [\"apple\"] }<\/code><\/pre>\n<h4>\u041e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u0441\u0442\u0435\u043a\u0438<\/h4>\n<p>\u041e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/FIFO\">FIFO<\/a>, \u0430 \u0441\u0442\u0435\u043a \u2014 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/LIFO\">LIFO<\/a>. \u0421 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u043c\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u0442\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441 \u043b\u044e\u0431\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ Stack \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u0435\u043a. type Stack[T any] struct {     elements []T }  \/\/ Push \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u0442\u0435\u043a. func (s *Stack[T]) Push(value T) {     s.elements = append(s.elements, value) }  \/\/ Pop \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u0442\u0435\u043a\u0430. func (s *Stack[T]) Pop() (T, bool) {     if len(s.elements) == 0 {         var zero T \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043d\u0443\u043b\u0435\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0442\u0438\u043f\u0430 T.         return zero, false     }     last := s.elements[len(s.elements)-1]     s.elements = s.elements[:len(s.elements)-1]     return last, true }  func main() {     stack := Stack[int]{}     stack.Push(1)     stack.Push(2)     fmt.Println(stack.Pop()) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: 2 true     fmt.Println(stack.Pop()) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: 1 true     fmt.Println(stack.Pop()) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: 0 false (\u0441\u0442\u0435\u043a \u043f\u0443\u0441\u0442) } <\/code><\/pre>\n<h4>\u0414\u0435\u0440\u0435\u0432\u044c\u044f<\/h4>\n<p>\u0421 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u043c\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0435\u0440\u0435\u0432\u044c\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0423\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ TreeNode \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0443\u0437\u0435\u043b \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435 \u043f\u043e\u0438\u0441\u043a\u0430. type TreeNode[T any] struct {     Value T     Left  *TreeNode[T]     Right *TreeNode[T] }  \/\/ Insert \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u043f\u043e\u0438\u0441\u043a\u0430. func (n *TreeNode[T]) Insert(value T, compare func(a, b T) int) {     if compare(value, n.Value) &lt; 0 {         if n.Left == nil {             n.Left = &amp;TreeNode[T]{Value: value}         } else {             n.Left.Insert(value, compare)         }     } else {         if n.Right == nil {             n.Right = &amp;TreeNode[T]{Value: value}         } else {             n.Right.Insert(value, compare)         }     } }  \/\/ InOrder \u043e\u0431\u0445\u043e\u0434\u0438\u0442 \u0434\u0435\u0440\u0435\u0432\u043e \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044f. func (n *TreeNode[T]) InOrder(visit func(T)) {     if n == nil {         return     }     n.Left.InOrder(visit)     visit(n.Value)     n.Right.InOrder(visit) }  func main() {     root := &amp;TreeNode[int]{Value: 5}     root.Insert(3, func(a, b int) int { return a - b })     root.Insert(7, func(a, b int) int { return a - b })     root.Insert(1, func(a, b int) int { return a - b })     root.Insert(9, func(a, b int) int { return a - b })      root.InOrder(func(value int) {         fmt.Println(value)     })     \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442 \u0447\u0438\u0441\u043b\u0430 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044f: 1, 3, 5, 7, 9 }<\/code><\/pre>\n<h4>\u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430<\/h4>\n<p>QuickSort \u2014 \u044d\u0442\u043e \u0431\u0430\u0437\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0437\u043d\u0430\u0435\u0442 \u043a\u0430\u0436\u0434\u044b\u0439. \u041e\u043d \u0431\u044b\u0441\u0442\u0440, \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u0438, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u043c, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043b\u044e\u0431\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ QuickSort \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0441\u043b\u0430\u0439\u0441 \u043b\u044e\u0431\u043e\u0433\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u043c\u043e\u0433\u043e \u0442\u0438\u043f\u0430. func QuickSort[T any](data []T, compare func(a, b T) bool) {     if len(data) &lt; 2 {         return     }     left, right := 0, len(data)-1     pivot := len(data) \/ 2     data[pivot], data[right] = data[right], data[pivot]     for i := range data {         if compare(data[i], data[right]) {             data[left], data[i] = data[i], data[left]             left++         }     }     data[left], data[right] = data[right], data[left]     QuickSort(data[:left], compare)     QuickSort(data[left+1:], compare) }  func main() {     slice := []int{9, 4, 6, 2, 10, 3}     QuickSort(slice, func(a, b int) bool { return a &lt; b })     fmt.Println(slice) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: [2 3 4 6 9 10] } =<\/code><\/pre>\n<h4>Binary search<\/h4>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ BinarySearch \u0438\u0449\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0430\u0439\u0441\u0435 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441. func BinarySearch[T any](data []T, target T, compare func(a, b T) int) int {     low, high := 0, len(data)-1     for low &lt;= high {         mid := (low + high) \/ 2         comparison := compare(data[mid], target)         if comparison == 0 {             return mid         } else if comparison &lt; 0 {             low = mid + 1         } else {             high = mid - 1         }     }     return -1 }  func main() {     slice := []int{2, 3, 4, 6, 9, 10}     fmt.Println(BinarySearch(slice, 6, func(a, b int) int { return a - b })) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: 3 } <\/code><\/pre>\n<h4>\u0424\u0430\u0431\u0440\u0438\u043a\u0438<\/h4>\n<p>\u0421 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u043c\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0431\u0440\u0438\u043a\u0438, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0435 \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ Creator \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u0438. type Creator[T any] func() T  \/\/ NewInstance \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0442\u0438\u043f\u0430 T. func NewInstance[T any](create Creator[T]) T {     return create() }  \/\/ \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0442\u0438\u043f\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c. type (     Book struct{ Title string }     Game struct{ Name string } )  func main() {     bookCreator := func() Book { return Book{Title: \"The Go Programming Language\"} }     gameCreator := func() Game { return Game{Name: \"Cyberpunk 2077\"} }      book := NewInstance(bookCreator)     game := NewInstance(gameCreator)      fmt.Println(book.Title) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: The Go Programming Language     fmt.Println(game.Name)  \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: Cyberpunk 2077 }<\/code><\/pre>\n<h4>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b<\/h4>\n<p>\u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c. \u0421 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u043c\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u043b\u044e\u0431\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ Decorator \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u043d\u043e\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c. func Decorator[T any](fn func(T), decorator func(T) T) func(T) {     return func(input T) {         fn(decorator(input))     } }  func main() {     print := func(n int) { fmt.Println(\"Number:\", n) }     double := func(n int) int { return n * 2 }      decorated := Decorator(print, double)     decorated(5) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: Number: 10 }<\/code><\/pre>\n<hr\/>\n<p>\u0414\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0435 \u0438 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b. <\/p>\n<p>\u041d\u043e\u0432\u0438\u0447\u043a\u0438, \u043f\u043e\u043c\u043d\u0438\u0442\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 &#8212; \u044d\u0442\u043e \u043d\u0435 \u043f\u0430\u043d\u0430\u0446\u0435\u044f \u0438 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0437\u0434\u0435. \u0418\u043d\u043e\u0433\u0434\u0430 \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u0434.<\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0441 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043d\u0430 <a href=\"https:\/\/go.dev\/doc\/tutorial\/generics\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435 golang<\/a>. \u0410 \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0441\u0432\u043e\u0438\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0437\u0430\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u0439\u0442\u0435 \u0432 <a href=\"https:\/\/otus.pw\/ZtyU\/\">\u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u043e\u043d\u043b\u0430\u0439\u043d-\u043a\u0443\u0440\u0441\u043e\u0432 OTUS<\/a>, \u043e\u0442 \u0432\u0435\u0434\u0443\u0449\u0438\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0442\u043e\u0432 \u0438\u043d\u0434\u0443\u0441\u0442\u0440\u0438\u0438.<\/p>\n<p><em>Keep coding, keep improving<\/em>, \u0438 \u0434\u043e \u043d\u043e\u0432\u044b\u0445 \u0432\u0441\u0442\u0440\u0435\u0447 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435.<\/p>\n<p>\u0438&#8230; \u0441 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u044e\u0449\u0438\u043c \u041d\u043e\u0432\u044b\u043c \u0413\u043e\u0434\u043e\u043c! ?<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/782414\/\"> https:\/\/habr.com\/ru\/articles\/782414\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p><em>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/em><\/p>\n<p>\u0414\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 (\u0438\u043b\u0438 generics) \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a Java, C#, \u0438 Rust, \u043d\u043e \u0434\u043b\u044f Go \u044d\u0442\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u043e\u0432\u0430\u044f \u0444\u0438\u0447\u0430, \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u0430\u044f \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 1.18.<\/p>\n<p>\u0414\u043e \u0432\u0435\u0440\u0441\u0438\u0438 1.18 Go \u0431\u044b\u043b \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u0441\u0432\u043e\u0438\u043c \u0441\u0442\u0440\u043e\u0433\u0438\u043c \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c \u043a \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438. \u041e\u0434\u043d\u0430\u043a\u043e, \u0441 \u0440\u043e\u0441\u0442\u043e\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u0430\u043b\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043d\u0443\u0436\u0435\u043d \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412\u0441\u0435 \u0432\u0435\u0447\u043d\u043e \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438, \u043a\u043e\u0433\u0434\u0430 \u0438\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0438 \u043f\u0443\u0441\u0442\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b.<\/p>\n<p>Go \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u044e \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u043b\u0433\u0438\u0445 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0439 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0439 \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 1.18. \u042d\u0442\u043e \u0431\u044b\u043b \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u043f\u0440\u043e\u0441\u044c\u0431\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430. + \u043a \u043a\u0430\u0440\u043c\u0435<\/p>\n<p>\u0414\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0441\u0442\u044b\u0439 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u043a\u043e\u0434. \u0412\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0435 \u043e\u0431\u0449\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0438 \u0437\u0430\u0442\u0435\u043c \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u0441 \u043b\u044e\u0431\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>\u041a\u0440\u0430\u0442\u043a\u043e \u043f\u0440\u043e\u0439\u0434\u0435\u043c\u0441\u044f \u043f\u043e \u0431\u0430\u0437\u0435:<\/p>\n<h4>\u0422\u0438\u043f\u044b \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/h4>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u043b\u044e\u0431\u043e\u0433\u043e \u0441\u043b\u0430\u0439\u0441\u0430. \u0411\u0435\u0437 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432 \u0432\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u043e \u0441 Type Parameters \u0432\u044b \u043f\u0438\u0448\u0435\u0442\u0435 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"go\">func First[T any](s []T) T {     return s[0] }<\/code><\/pre>\n<p><code>T<\/code> \u2014 \u044d\u0442\u043e type parameter. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0447\u0435\u043c \u0443\u0433\u043e\u0434\u043d\u043e: int, string, \u0432\u0430\u0448\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u0442\u0438\u043f\u043e\u043c, \u0447\u0435\u043c \u0443\u0433\u043e\u0434\u043d\u043e. \u0410 <code>any<\/code> \u2014 \u044d\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043b\u044e\u0431\u044b\u043c \u0442\u0438\u043f\u043e\u043c<\/p>\n<h4>Type set<\/h4>\n<p>Type Sets (\u0432 Go \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u043d\u0438\u0436\u0435 1.18 \u043d\u0430\u0437\u044b\u0432\u0430\u043b\u0438\u0441\u044c Contracts) \u2014 \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043d\u0430 \u0442\u0438\u043f\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0441 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u043c\u0438. <\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u044b \u043f\u0438\u0448\u0435\u0442\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438. \u0411\u0435\u0437 Contracts \u0432\u044b \u0431\u044b\u043b\u0438 \u0431\u044b \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u044b \u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0434\u043e\u0431\u0440\u043e\u0441\u043e\u0432\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 (\u0438 \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u043d\u0430\u0434\u0435\u0436\u043d\u043e). \u041d\u043e \u0441 Contracts \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0430\u0448\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0442\u0438\u043f\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"go\">type Number interface {     int | float64 \/\/ \u0442\u043e\u043b\u044c\u043a\u043e \u0446\u0435\u043b\u044b\u0435 \u0438 \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430. }  func Sum[T Number](a, b T) T {     return a + b }<\/code><\/pre>\n<h4>Type inference  <\/h4>\n<p>Type inference \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0443\u0433\u0430\u0434\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u044b \u0438\u043c\u0435\u0435\u0442\u0435 \u0432 \u0432\u0438\u0434\u0443, \u043d\u0435 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0432\u0430\u0441 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u043c\u0435\u043b\u043e\u0447\u044c. \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u043c\u0438, Go \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u043d\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0442\u0438\u043f\u044b \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ Generic \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043b\u044e\u0431\u044b\u043c \u0442\u0438\u043f\u043e\u043c. func Print[T any](s T) {     fmt.Println(s) }  func main() {     \/\/ Go \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0442\u0438\u043f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 T \u043a\u0430\u043a int.     Print(123)      \/\/ Go \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0442\u0438\u043f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 T \u043a\u0430\u043a string.     Print(\"Hello, Generics!\") }<\/code><\/pre>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 Go \u043c\u043e\u0436\u0435\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c: &#171;\u0423 \u0442\u0435\u0431\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432, \u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u0432\u044b\u0431\u0440\u0430\u0442\u044c.&#187; \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043a\u043e\u0433\u0434\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430, \u0438\u043b\u0438 \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u0448 \u043a\u043e\u0434 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0433\u0430\u0434\u043e\u0447\u0435\u043d, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u0443\u043c\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432 \u0441\u0442\u0443\u043f\u043e\u0440\u0435:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  func Merge[T any, U any](first T, second U) {     fmt.Println(first, second) }  func main() {     \/\/ \u044f\u0432\u043d\u043e\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0442\u0430\u043a \u043a\u0430\u043a Go \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0438\u0445     Merge[int, string](42, \"The answer is\") }<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 Go \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0442\u0438\u043f, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u0430\u0442\u044c \u0435\u043c\u0443 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0443, \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0432 \u0442\u0438\u043f \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u0430\u043a \u0432 11 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 \u043a\u043e\u0434\u0430 \u0432\u044b\u0448\u0435.<\/p>\n<p>\u0412\u0441\u0435 \u044d\u0442\u043e \u0437\u0432\u0443\u0447\u0438\u0442 \u043a\u043b\u0430\u0441\u0441\u043d\u043e, \u043d\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 \u2014 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0430\u0445\u0430\u0440, \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430.  \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043b\u0438 \u0442\u0438\u043f\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u043b\u0438 \u0442\u0438\u043f\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<h2>\u0414\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438 \u0432 Go<\/h2>\n<h4>Constraints \u0438 type sets<\/h4>\n<p>Constraints, \u0438\u043b\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 &#8212; \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0432 \u043d\u0430\u0448\u0438\u0445 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u0445. <\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0447\u0438\u0441\u043b\u0430\u043c\u0438. \u0411\u0435\u0437 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432, \u0432\u0430\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f <code>int<\/code>, <code>float64<\/code>, \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u041d\u043e \u0441 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u043c\u0438 \u0438 constraints, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0430\u0445\u0443. \u0412\u043e\u0442 \u043a\u0430\u043a:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043d\u0430\u0448 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 constraint. type Number interface {     int | float64 \/\/ \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c int \u0438\u043b\u0438 float64. }  \/\/ UniversalAdd \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0432 Number. func UniversalAdd[T Number](a, b T) T {     return a + b }  func main() {     \/\/ \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 int.     fmt.Println(UniversalAdd[int](1, 2))      \/\/ \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 float64.     fmt.Println(UniversalAdd[float64](1.5, 2.3)) }<\/code><\/pre>\n<p> <code>UniversalAdd<\/code> &#8212; \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0432 <code>Number<\/code>. \u042d\u0442\u043e \u043e\u0447. \u0443\u0434\u043e\u0431\u043d\u043e. \u041e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0445 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<p>\u0412\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h4>comparable, any<\/h4>\n<p><code>comparable<\/code> &#8212; \u044d\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c, \u0447\u0442\u043e \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 <code>==<\/code> \u0438 <code>!=<\/code>:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ Distinct \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u044d\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u0441\u043b\u0430\u0439\u0441\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b func Distinct[T comparable](list []T) []T {     unique := make(map[T]bool)     var result []T     for _, item := range list {         if !unique[item] {             unique[item] = true             result = append(result, item)         }     }     return result }  func main() {     \/\/ \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043b\u044e\u0431\u044b\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u043c\u044b\u043c \u0442\u0438\u043f\u043e\u043c     fmt.Println(Distinct([]int{1, 2, 2, 3, 4, 4, 4, 5}))     fmt.Println(Distinct([]string{\"\u043a\u043e\u0442\u0438\u043a\", \"\u043a\u043e\u0448\u0435\u0447\u043a\u0430\", \"\u043a\u043e\u0442\", \"\u043a\u043e\u0448\u043a\u0430\"})) }<\/code><\/pre>\n<p><code>Distinct<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>comparable<\/code> \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u043e\u0432 \u0438\u0437 \u0441\u043b\u0430\u0439\u0441\u0430. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a <code>any<\/code>. \u042d\u0442\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432 Go, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043f\u043e \u0441\u0443\u0442\u0438, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0447\u0435\u043c \u0443\u0433\u043e\u0434\u043d\u043e:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ PrintAny \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043b\u0430\u0439\u0441 \u043b\u044e\u0431\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0438\u0445. func PrintAny(items []any) {     for _, item := range items {         fmt.Println(item)     } }  func main() {     \/\/ \u041c\u043e\u0436\u0435\u043c \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445!     PrintAny([]any{1, \"apple\", true, 3.14}) }<\/code><\/pre>\n<p><code>PrintAny<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043b\u0430\u0439\u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0438 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0438\u0445. <\/p>\n<h4>\u0423\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h4>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043a\u043b\u0430\u0441\u0441\u0438\u043a\u0438 &#8212; \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u043c\u0435\u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, <code>Swap<\/code>. \u0411\u0435\u0437 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u043e\u0432, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0441 \u043d\u0438\u043c\u0438 \u0432\u0441\u0435 \u0433\u043e\u0440\u0430\u0437\u0434\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ Swap \u043c\u0435\u043d\u044f\u0435\u0442 \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430. func Swap[T any](a, b *T) {     *a, *b = *b, *a }  func main() {     x := 1     y := 2     Swap(&amp;x, &amp;y)     fmt.Println(x, y) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: 1 2      s1 := \"Hello\"     s2 := \"Habr\"     Swap(&amp;s1, &amp;s2)     fmt.Println(s1, s2) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: Hello Habr }<\/code><\/pre>\n<p><code>Swap<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>any<\/code>, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043b\u044e\u0431\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u043e \u043a\u0430\u043a \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u043a \u043c\u0438\u0440\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445!<\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0447\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0435 &#8212; \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u044d\u0448\u0430:<\/h3>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ Cache - \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043a\u044d\u0448\u0430. \/\/ T - \u0442\u0438\u043f \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. type Cache[T any] struct {     store map[string]T }  \/\/ NewCache \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 Cache. func NewCache[T any]() *Cache[T] {     return &amp;Cache[T]{store: make(map[string]T)} }  \/\/ Set \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043a\u044d\u0448. func (c *Cache[T]) Set(key string, value T) {     c.store[key] = value }  \/\/ Get \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u043a\u044d\u0448\u0430. func (c *Cache[T]) Get(key string) (T, bool) {     val, found := c.store[key]     return val, found }  func main() {     \/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u044d\u0448 \u0434\u043b\u044f int.     intCache := NewCache[int]()     intCache.Set(\"key1\", 10)     fmt.Println(intCache.Get(\"key1\")) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: 10 true      \/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u044d\u0448 \u0434\u043b\u044f string.     stringCache := NewCache[string]()     stringCache.Set(\"hello\", \"world\")     fmt.Println(stringCache.Get(\"hello\")) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: world true }<\/code><\/pre>\n<p><code>Cache<\/code> &#8212; \u044d\u0442\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u044d\u0448 \u0434\u043b\u044f \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b, \u0441\u0442\u0440\u043e\u043a, \u0438\u043b\u0438 \u0447\u0435\u0433\u043e \u0443\u0433\u043e\u0434\u043d\u043e, \u0447\u0442\u043e \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435.<\/p>\n<h2>\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435<\/h2>\n<h4>\u0421\u043b\u0430\u0439\u0441\u044b: <\/h4>\n<p>\u0421\u043b\u0430\u0439\u0441\u044b \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0441\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u0441\u0436\u0438\u043c\u0430\u0442\u044c\u0441\u044f, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044f \u043d\u0430 \u0441\u0435\u0431\u044f \u0432\u0441\u0435, \u0447\u0442\u043e \u0432\u044b \u0438\u043c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u0435. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u043b\u0430\u0439\u0441\u0430\u043c\u0438 \u043b\u044e\u0431\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ Filter \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043b\u0430\u0439\u0441 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f \u043d\u043e\u0432\u044b\u0439 \u0441\u043b\u0430\u0439\u0441 \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0438\u043c\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044e. func Filter[T any](slice []T, predicate func(T) bool) []T {     var result []T     for _, v := range slice {         if predicate(v) {             result = append(result, v)         }     }     return result }  func main() {     \/\/ \u0424\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u043c \u0441\u043b\u0430\u0439\u0441 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b.     ints := []int{1, 2, 3, 4, 5}     even := Filter(ints, func(n int) bool { return n%2 == 0 })     fmt.Println(even) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: [2 4]      \/\/ \u0424\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u043c \u0441\u043b\u0430\u0439\u0441 \u0441\u0442\u0440\u043e\u043a.     strings := []string{\"apple\", \"banana\", \"cherry\"}     withA := Filter(strings, func(s string) bool { return s[0] == 'a' })     fmt.Println(withA) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: [\"apple\"] }<\/code><\/pre>\n<h4>\u041e\u0447\u0435\u0440\u0435\u0434\u0438 \u0438 \u0441\u0442\u0435\u043a\u0438<\/h4>\n<p>\u041e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/FIFO\">FIFO<\/a>, \u0430 \u0441\u0442\u0435\u043a \u2014 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/LIFO\">LIFO<\/a>. \u0421 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u043c\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u0442\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441 \u043b\u044e\u0431\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ Stack \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u0435\u043a. type Stack[T any] struct {     elements []T }  \/\/ Push \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u0442\u0435\u043a. func (s *Stack[T]) Push(value T) {     s.elements = append(s.elements, value) }  \/\/ Pop \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u0442\u0435\u043a\u0430. func (s *Stack[T]) Pop() (T, bool) {     if len(s.elements) == 0 {         var zero T \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043d\u0443\u043b\u0435\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0442\u0438\u043f\u0430 T.         return zero, false     }     last := s.elements[len(s.elements)-1]     s.elements = s.elements[:len(s.elements)-1]     return last, true }  func main() {     stack := Stack[int]{}     stack.Push(1)     stack.Push(2)     fmt.Println(stack.Pop()) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: 2 true     fmt.Println(stack.Pop()) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: 1 true     fmt.Println(stack.Pop()) \/\/ \u0412\u044b\u0432\u0435\u0434\u0435\u0442: 0 false (\u0441\u0442\u0435\u043a \u043f\u0443\u0441\u0442) } <\/code><\/pre>\n<h4>\u0414\u0435\u0440\u0435\u0432\u044c\u044f<\/h4>\n<p>\u0421 \u0434\u0436\u0435\u043d\u0435\u0440\u0438\u043a\u0430\u043c\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0435\u0440\u0435\u0432\u044c\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0423\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"go\">package main  import \"fmt\"  \/\/ TreeNode \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0443\u0437\u0435\u043b \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435 \u043f\u043e\u0438\u0441\u043a\u0430. type TreeNode[T any] struct {     Value T     Left  *TreeNode[T]     Right *TreeNode[T] }  \/\/ Insert \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u043f\u043e\u0438\u0441\u043a\u0430. func (n *TreeNode[T]) Insert(value T, compare func(a, b T) int) {     if compare(value, n.Value) &lt; 0 {         if n.Left == nil {             n.Left = &amp;TreeNode[T]{Value: value}         } else {             n.Left.Insert(value, compare)         }     } else {         if n.Right == nil {             n.Right = &amp;TreeNode[T]{Value: value}    <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-363683","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/363683","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=363683"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/363683\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=363683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=363683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=363683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}