{"id":2473,"date":"2018-10-09T07:02:03","date_gmt":"2018-10-08T22:02:03","guid":{"rendered":"http:\/\/okamurax.com\/?p=2473"},"modified":"2020-05-06T00:17:42","modified_gmt":"2020-05-05T15:17:42","slug":"golang-%e7%b0%a1%e6%98%93%e3%83%86%e3%82%b9%e3%83%88%e5%ae%9f%e6%96%bd","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=2473","title":{"rendered":"golang \u7c21\u6613\u30c6\u30b9\u30c8\u5b9f\u65bd"},"content":{"rendered":"<pre class=\"lang:go decode:true \">package FileList\r\n\r\ntype FileList struct {\r\n\tlists []string\r\n}\r\n\r\nfunc NewList() *FileList {\r\n\tc := new(FileList)\r\n\tc.lists = make([]string, 0)\r\n\treturn c\r\n}\r\n\r\nfunc (c *FileList) Add(s string) {\r\n\tc.lists = append(c.lists, s)\r\n}\r\n\r\nfunc (c *FileList) GetAll() []string {\r\n\treturn c.lists\r\n}\r\n<\/pre>\n<pre class=\"lang:go decode:true \">package FileList\r\n\r\nimport (\r\n\t\"log\"\r\n\t\"testing\"\r\n)\r\n\r\n\/\/TestXXX\u3068\u3059\u308b\r\nfunc TestA(t *testing.T) {\r\n\r\n\tfileList := NewList()\r\n\tfileList.Add(\"\u925b\u7b46\")\r\n\tfileList.Add(\"\u30dc\u30fc\u30eb\u30da\u30f3\")\r\n\r\n\tf := fileList.GetAll()\r\n\tif len(f) != 2 {\r\n\t\tt.Fatalf(\"length error %d\", len(f))\r\n\t\t\/\/Fatal\u306f\u5931\u6557\u6642\u30c6\u30b9\u30c8\u7d42\u4e86\r\n\t}\r\n\r\n\tif f[1] != \"\u925b\u7b46\" {\r\n\t\tt.Error(\"\u925b\u7b46\u306a\u3057\")\r\n\t\tt.Log(f)\r\n\t}\r\n\r\n\tlog.Print(\"done\")\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>package FileList type FileList struct { lists []string } func NewList() *FileList { c := new(FileList) c.lists &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=2473\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;golang \u7c21\u6613\u30c6\u30b9\u30c8\u5b9f\u65bd&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[148],"class_list":["post-2473","post","type-post","status-publish","format-standard","hentry","category-1","tag-golang"],"_links":{"self":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2473"}],"version-history":[{"count":1,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2473\/revisions"}],"predecessor-version":[{"id":2474,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2473\/revisions\/2474"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}