{"id":3916,"date":"2023-08-09T20:30:46","date_gmt":"2023-08-09T11:30:46","guid":{"rendered":"https:\/\/dennie.tokyo\/it\/?p=3916"},"modified":"2023-08-09T20:34:25","modified_gmt":"2023-08-09T11:34:25","slug":"%e3%80%90go%e3%80%91%e5%9e%8b%e3%82%a2%e3%82%b5%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3","status":"publish","type":"post","link":"https:\/\/dennie.tokyo\/it\/?p=3916","title":{"rendered":"\u3010Go\u3011\u578b\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3"},"content":{"rendered":"\n<p>\u95a2\u6570\u3084\u30e1\u30bd\u30c3\u30c8\u306e\u5f15\u6570\u304c\u7a7a\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u5834\u5408\u3001\u53d7\u3051\u53d6\u3063\u305f\u5f15\u6570\u3092\u4f7f\u7528\u3059\u308b\u6642\u306b\u3069\u306e\u3088\u3046\u306a\u578b\u306a\u306e\u304b\u5206\u304b\u308a\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>\u5f93\u3063\u3066\u3001\u578b\u3092\u5224\u65ad\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br>Go\u306b\u306f\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u304c\u3069\u306e\u578b\u306a\u306e\u304b\u3092\u5224\u5b9a\u3059\u308b\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u306a\u304a\u3001\u7a7a\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306b\u3064\u3044\u3066\u306f\u4ee5\u4e0b\u3092\u53c2\u7167\u3057\u3066\u4e0b\u3055\u3044\u3002<\/p>\n\n\n\n<div class=\"title_box\"><span class=\"box-title\">\u53c2\u8003<\/span>\n<p><\/p>\n<p><a href=\"https:\/\/dennie.tokyo\/it\/?p=3909\" rel=\"noopener\" target=\"_blank\">\u3010Go\u3011\u7a7a\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9<\/a><\/p>\n<\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u578b\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u306e\u57fa\u672c<\/h1>\n\n\n\n<p>\u578b\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u304c\u5b9f\u969b\u306b\u3069\u306e\u578b\u306a\u306e\u304b\u3092\u5224\u5b9a\u3057\u307e\u3059\u3002<br>\u307e\u305a\u3001\u578b\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u306f\u4ee5\u4e0b\u306e\u5f62\u5f0f\u3067\u671f\u5f85\u3059\u308b\u578b\u3092\u53d7\u3051\u53d6\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>\u671f\u5f85\u3059\u308b\u578b := \u5909\u6570.(\u671f\u5f85\u3059\u308b\u578b)<\/code><\/pre><\/div>\n\n\n\n<p>\u5b9f\u969b\u306e\u578b\u3068\u671f\u5f85\u3059\u308b\u578b\u304c\u7570\u306a\u308b\u5834\u5408\u30d1\u30cb\u30c3\u30af\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u30ab\u30f3\u30de ok \u30a4\u30c7\u30a3\u30aa\u30e0 \u3092\u4f7f\u3063\u3066\u671f\u5f85\u3057\u305f\u578b\u3060\u3063\u305f\u304b\u3092\u5224\u5b9a\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>\u671f\u5f85\u3059\u308b\u578b, \u5224\u5b9a\u7d50\u679c := \u5909\u6570.(\u671f\u5f85\u3059\u308b\u578b)<\/code><\/pre><\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u578b\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u306e\u4f8b<\/h1>\n\n\n\n<p>\u4ee5\u4e0b\u306f\u5b9f\u969b\u306b\u578b\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>package main\n\nimport (\n\t&quot;fmt&quot;\n)\n\n\/\/ \u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u5b9a\u7fa9\ntype myInterface interface {\n\tgetName() string\n}\n\n\/\/ \u72ac\u306e\u69cb\u9020\u4f53\u306e\u5b9a\u7fa9\ntype dog struct {\n\tname string\n}\n\n\/\/ \u72ac\u306e\u30e1\u30bd\u30c3\u30c8\u5b9a\u7fa9\nfunc (d dog) getName() string {\n\treturn d.name\n}\n\nfunc main() {\n\td := dog{}\n\td.name = &quot;dog_name&quot;\n\tdetermineType(d) \/\/ dog_name \u304c\u8868\u793a\u3055\u308c\u308b\n\n\ti := 1\n\tdetermineType(i) \/\/ \u4e88\u671f\u305b\u306c\u578b\u3067\u3059 \u304c\u8868\u793a\u3055\u308c\u308b\n}\n\nfunc determineType(m interface{}) {\n\n\t\/\/ \u578b\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u3002\u30ab\u30f3\u30de ok \u30a4\u30c7\u30a3\u30aa\u30e0 \u3092\u4f7f\u3063\u3066\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u578b\u3092\u5224\u5b9a\u3059\u308b\n\tdog, ok := m.(dog)\n\tif ok {\n\t\tfmt.Println(dog.getName())\n\t} else {\n\t\tfmt.Println(&quot;\u4e88\u671f\u305b\u306c\u578b\u3067\u3059&quot;)\n\t}\n}\n<\/code><\/pre><\/div>\n\n\n\n<p>determineType\u95a2\u6570\u306e\u5f15\u6570\u306f\u7a7a\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br>determineType\u95a2\u6570\u306f\u578b\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3057\u3066\u5f15\u6570\u304cdog\u578b\u3067\u3042\u308b\u5834\u5408\u3001dog\u578b\u306e\u30e1\u30bd\u30c3\u30c8(getName())\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>main\u95a2\u6570\u3067\u306f\u3001\u521d\u3081\u306bdog\u578b\u3092\u4f7f\u7528\u3057\u3066determineType\u95a2\u6570\u3092\u5b9f\u884c\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u70ba\u3001&#8221;dog_name&#8221; \u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<br>\u6b21\u306b\u3001\u6570\u5024\u30ea\u30c6\u30e9\u30eb\u3092\u3092\u4f7f\u7528\u3057\u3066determineType\u95a2\u6570\u3092\u5b9f\u884c\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u70ba\u3001&#8221;\u4e88\u671f\u305b\u306c\u578b\u3067\u3059&#8221; \u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u95a2\u6570\u3084\u30e1\u30bd\u30c3\u30c8\u306e\u5f15\u6570\u304c\u7a7a\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u5834\u5408\u3001\u53d7\u3051\u53d6\u3063\u305f\u5f15\u6570\u3092\u4f7f\u7528\u3059\u308b\u6642\u306b\u3069\u306e\u3088\u3046\u306a\u578b\u306a\u306e\u304b\u5206\u304b\u308a\u307e\u305b\u3093\u3002<\/p>\n","protected":false},"author":1,"featured_media":5,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[],"class_list":["post-3916","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-go"],"_links":{"self":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/3916","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3916"}],"version-history":[{"count":5,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/3916\/revisions"}],"predecessor-version":[{"id":3921,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/3916\/revisions\/3921"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/media\/5"}],"wp:attachment":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3916"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3916"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}