{"id":3624,"date":"2019-02-20T00:50:32","date_gmt":"2019-02-19T15:50:32","guid":{"rendered":"https:\/\/greentown.tokyo\/?p=3624"},"modified":"2019-02-21T01:57:51","modified_gmt":"2019-02-20T16:57:51","slug":"10minutes-go10","status":"publish","type":"post","link":"https:\/\/greentown.tokyo\/?p=3624","title":{"rendered":"10\u5206GO 10\u65e5\u76ee"},"content":{"rendered":"<p>\u3044\u305d\u304c\u3057\u3044\u3051\u3069\u3001\u30b3\u30c4\u30b3\u30c4\u3059\u308b\u3088\u3002<\/p>\n<h2>GO<\/h2>\n<h3>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9eGo<\/h3>\n<h6>\u7b2c\uff11\u7ae0\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u30001.3 \u91cd\u8907\u3057\u305f\u884c\u3092\u898b\u3064\u3051\u308b<\/h6>\n<p>dup1\u3084\u3063\u305f\u30fb\u30fb\u3093\u3067\u3059\u304c\u3001\u305f\u3060\u30b3\u30fc\u30c9\u3092\u5199\u3057\u305f\u3060\u3051\u3058\u3083\u3001\u52d5\u3044\u3066\u304f\u308c\u306a\u3044\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/Mikkegt\/gopl.io-ch1-echo1\/blob\/master\/ch1-dup1.go\">https:\/\/github.com\/Mikkegt\/gopl.io-ch1-echo1\/blob\/master\/ch1-dup1.go<\/a><\/p>\n<p>\u3080\u3080\u3045\u3002\u6700\u5f8c\u306e\u3001printf\u306e\u3068\u3053\u308d\u304c\u51fa\u306a\u3044\u3002\u306a\u305c\u3058\u3083\u3002<\/p>\n<p>\u3053\u306e\u8abf\u5b50\u3060\u3068\u3001\u7b2c\uff11\u7ae0\u7d42\u308f\u3089\u305b\u308b\u306e\u306b\uff12\u9031\u9593\u304f\u3089\u3044\u304b\u304b\u308a\u305d\u3046\u3002<\/p>\n<h3>Print\u6587<\/h3>\n<h6>Print()<\/h6>\n<pre class=\"lang:go decode:true \">fmt.Print(\"Hello world!\")<\/pre>\n<p>Hello world!<\/p>\n<p>&nbsp;<\/p>\n<h6>Fprint()\u3001Fprintf()\u3001Fprintln()<\/h6>\n<p>F\u3092\u5148\u982d\u306b\u3064\u3051\u308b\u3068\u3001\u66f8\u304d\u8fbc\u307f\u5148\u304c\u6307\u5b9a\u3067\u304d\u308b\u3002<\/p>\n<pre class=\"lang:go decode:true\">fmt.Fprint(os.Stdout, \"Hello world!\")<\/pre>\n<p>Hello world!<\/p>\n<p>&nbsp;<\/p>\n<h6>Println()\u3001Fpirntln()\u3001Spirntln()<\/h6>\n<p>\u304a\u3057\u308a\u306bln\u304c\u3064\u3044\u3066\u3044\u308b print\u6587\u306f\u3001\u30aa\u30da\u30e9\u30f3\u30c9\u306e\u9593\u306b\u534a\u89d2\u30b9\u30da\u30fc\u30b9\u304c\u5165\u308b\u3002\u3064\u3044\u3067\u306b\u6539\u884c\u3057\u3066\u304f\u308c\u308b\u3002<\/p>\n<pre class=\"lang:go decode:true \">fmt.Println(\"Hello\", \"world!\")<\/pre>\n<p>Hello\u00a0world!\uff08\u6539\u884c\u3055\u308c\u308b\uff09<\/p>\n<p>&nbsp;<\/p>\n<h6>Sprint()\u3001Sprintf()\u3001Splintln()<\/h6>\n<p>\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3057\u305f\u7d50\u679c\u3092\u8fd4\u3059\u3002\u6a19\u6e96\u51fa\u529b\u306f\u3057\u306a\u3044\u3002<\/p>\n<pre class=\"lang:go decode:true\">hope := fmt.Sprint(\"Hello world!\")\r\nfmt.Print(hoge)<\/pre>\n<p>Hello world!<\/p>\n<h3>\u69cb\u9020\u4f53\u306e\u4e2d\u8eab\u3092json\u306b\u3057\u3066print\u6587\u3059\u308b<\/h3>\n<p>mongo\u304b\u3089\u3068\u3063\u3066\u304d\u305f\u30c7\u30fc\u30bf\u30fc\u3092\u69cb\u9020\u4f53\u306b\u5165\u308c\u308b\u307e\u3067\u306f\u3067\u304d\u305f\u306e\u3067\u3059\u304c\u3001\u30d6\u30e9\u30a6\u30b6\u306b\u3069\u3046\u3060\u305d\u3046\u304b\u3068\u3042\u308c\u3053\u308c\u8a66\u3057\u305f\u306e\u3067\u3059\u304c\u3001\u306a\u304b\u306a\u304b\u3046\u307e\u304f\u3067\u304d\u305a\u30fb\u30fb<\/p>\n<pre class=\"lang:go decode:true \">type Hoge struct {\r\n    Id      bson.ObjectId `bson:\"_id\"`\r\n    name    string        `bson:\"name\"`\r\n    Text[]  string        `bson:\"text\"`\r\n}\r\n<\/pre>\n<p>\u3053\u3093\u306a\u69cb\u9020\u4f53\u304c\u3042\u3063\u305f\u3068\u3057\u3066\u3001\u69cb\u9020\u4f53\u3001\u914d\u5217\u3060\u3057\u30fb\u30fb\u3002\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u305f\u3089\u3067\u304d\u305f\u3002<\/p>\n<pre class=\"lang:go decode:true\">import \"encoding\/json\"\r\n    \uff08\u4e2d\u7565\uff09\r\n    var hoge []Hoge\r\n    if err := c.Find(nil).All(&amp;hoge); err != nil {\r\n        log.Fatal(err)\r\n    }\r\n    b, _ := json.Marshal(hoge)\r\n    fmt.Fprintf(w, \"%s\", b)<\/pre>\n<p>json.Marshal(hoge)<\/p>\n<p>\u3053\u306e\u90e8\u5206\u3002\u69cb\u9020\u4f53\u306e\u4e2d\u8eab\u3092\u5168\u90e8 json\u306b\u5909\u63db\u3057\u3066\u304f\u308c\u308b\u3002<\/p>\n<p>print\u6587\u306b\u7a81\u3063\u8fbc\u3093\u3060\u3089\u3001\u30d6\u30e9\u30a6\u30b6\u306b\u8868\u793a\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u4eca\u65e5\u306f\u5b89\u7720\u3067\u304d\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>\u660e\u65e5\u306fGo\u306e\u304a\u52c9\u5f37\u4f1a\u306b\u3044\u3063\u3066\u304d\u307e\u3059\u3002<\/p>\n<p>Go\u597d\u304d\u306a\u5973\u5b50\u3070\u304b\u308a\u3067\u3001\u307b\u3093\u308f\u304b\u3057\u3066\u3044\u3066\u697d\u3057\u3044\u3093\u3060\u306a\u3041\u301c<\/p>\n<p>\u4eca\u56de\u306f\u3001GAE\u4e0a\u306b\u5bb6\u8a08\u7c3f\u4f5c\u308b\u3093\u3060\u3063\u3066\u3002<\/p>\n<p>\u307e\u305f\u611f\u60f3\u66f8\u304d\u307e\u3059\u301c<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3044\u305d\u304c\u3057\u3044\u3051\u3069\u3001\u30b3\u30c4\u30b3\u30c4\u3059\u308b\u3088\u3002 GO \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9eGo \u7b2c\uff11\u7ae0\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u30001.3 \u91cd\u8907\u3057\u305f\u884c\u3092\u898b\u3064\u3051\u308b dup1\u3084\u3063\u305f\u30fb\u30fb\u3093\u3067\u3059\u304c\u3001\u305f\u3060\u30b3\u30fc\u30c9\u3092\u5199\u3057\u305f\u3060\u3051\u3058\u3083\u3001\u52d5\u3044\u3066\u304f\u308c\u306a\u3044\u3002 https &#8230; <\/p>\n","protected":false},"author":1,"featured_media":3514,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[95],"tags":[],"class_list":["post-3624","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-golang"],"_links":{"self":[{"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/posts\/3624"}],"collection":[{"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3624"}],"version-history":[{"count":15,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/posts\/3624\/revisions"}],"predecessor-version":[{"id":3640,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/posts\/3624\/revisions\/3640"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=\/wp\/v2\/media\/3514"}],"wp:attachment":[{"href":"https:\/\/greentown.tokyo\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/greentown.tokyo\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}