何か変わった

# サンプルを探す
- ああでもない、こうでもないと試行錯誤しても上手くいかず
- でも参考文献として読んでいた多くのブログに「動くコードをコピーしてまず動かす。そこから部分的に修正してやりたい事を実際に動かすのよい」要はコピペを駆使して動かしてみましょう、と書いてあると解釈
- サーバーなりネットワーク機器だとパッケージをインストールした際にサンプルコンフィグがあって、それを修正して動作させる。その意識はあったが、プログラムってなんか手慣れた人達がさらさらさらさ～らっと書いて動かしているイメージがあった（個人的な印象です）

# 実際に探してみた
- ちょっと検索しただけでもすんごく出てきた :disappointed_relieved:
- 色々見ると自分には難しい。んでたどり着いたのが以下、これなら何となく分かった（気がする）
    - [Go by Example: HTTP Client](https://dlintw.github.io/gobyexample/public/http-client.html)

# 動かしてみた（コピペで）

```
$ go run http-client.org.go 
get:
 User-agent: *
Disallow: /search
Allow: /search/about
post:
 <!DOCTYPE html>
<!--[if IEMobile 7 ]> <html lang="en_US" class="no-js iem7"> <![endif]-->
<!--[if lt IE 7]> <html class="ie6 lt-ie10 lt-ie9 lt-ie8 lt-ie7 no-js" lang="en_US"> <![endif]-->
```

- `http.Get`の部分を`http://www.google.com/`にしてみた
    -（あたりまえだけど）すんげ～出た

```
$ go run http-client.go 
get:
 <!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content="Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for." name="description"><meta content="noodp" name="robots"><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/images/branding/googleg/1x/googleg_standard_color_128dp.png" itemprop="image"><title>Google</title><script nonce="SHnQTfU6Ib6WB7M7EohLwQ==">(function(){window.google={kEI:'iQzlXMfLNIKwsAWJjLeIDQ',kEXPI:'0,1353747,57,51,1907,1641,781,697,528,730,224,1575,1258,1894,56,321,207,1017,1187,162,2332255,329520,1294,12383,4855,32692,15247,867,12163,6381,3335,2,2,4609,2192,369,3314,5505,224,2218,260,5107,575,835,284,2,578,728,2432,58,2,1,3,1297,4323,3700,1268,773,2247,1410,3337,1146,5,2,2,1965,2593,3601,669,1050,1808,1397,81,7,1,2,488,620,29,1395,3610,3632,1667,1288,2,4007,796,101,1119,38,920,754,119,1217,1364,1611,2729,7,1558,1503,2,631,2562,2,4,2,678,37,369,1399,2889,124,2608,12,620,2228,655,17,321,236,1357,389,142,86,2,961,198,777,1,2,367,1016,301,704,756,98,36,2,366,18,399,259,733,509,598,10,168,8,109,187,831,235,810,450,904,155,82,48,459,94,11,14,10,1659,839,57,5,14,380,146,381,25,177,39,284,5,1252,66,91,141,542,92,1,231,164,3package main
0,530,267,11,93,112,125,1,35,25,217,10,39,18,22,16,158,1570,604,21,33,71,24,127,1,210,279,319,23,818,260,1187,1,3,7,7,1,2,53,1097,5,337,540,14,606,454,184,127,13,184,6,333,14,195,1,320,7,185,44,324,204,24,1081,242,15,363,24,275,58,4,128,1,12,104,61,599,12,1,30,144,1,4,1,1,4,1,1,479,119,130,34,782,340,767,73,4,29,314,1204,115,5931739,2885,5997591,2799864,4,1572,549,333,444,1,2,80,1,900,583,7,306,1,8,1,2,2132,1,1,1,1,1,414,1,748,141,59,726,3,7,563,1,2075,72,44,2,4,31,1,1,8,10,1,5,5,20747724,1557155',authuser:0,kscs:'c9c918f0_iQzlXMfLNIKwsAWJjLeIDQ',kGL:'US'};google.sn='webhp';google.kHL='en';})();(function(){google.lc=[];google.li=0;google.getEI=function(a){for(var b;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.parentNode;return b||google.kEI};google.getLEI=function(a){for(var b=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid")));)a=a.parentNode;return b};google.https=function(){return"https:"==window.location.protocol};google.ml=function(){return null};google.time=function(){return(new Date).getTime()};google.log=function(a,b,e,c,g){if(a=google.logUrl(a,b,e,c,g)){b=new Image;var d=google.lc,f=google.li;d[f]=b;b.onerror=b.onload=b.onabort=function(){delete d[f]};google.vel&&google.vel.lu&&google.vel.lu(a);b.src=a;google.li=f+1}};google.logUrl=function(a,b,e,c,g){var d="",f=google.ls||"";e||-1!=b.search("&ei=")||(d="&ei="+google.getEI(c),-1==b.search("&lei=")&&(c=google.getLEI(c))&&(d+="&lei="+c));c="";!e&&google.cshid&&-1==b.search("&cshid=")&&"slh"!=a&&(c="&cshid="+google.cshid);a=e||"/"+(g||"gen_204")+"?atyp=i&ct="+a+"&cad="+b+d+f+"&zx="+google.time()+c;/^http:/i.test(a)&&google.https()&&(google.ml(Error("a"),!1,{src:a,glmm:1}),a="");return a};}).call(this);(function(){google.y={};google.x=function(a,b){if(a)var c=a.id;else{do c=Math.random();while(google.y[c])}google.y[c]=[a,b];return!1};google.lm=[];google.plm=function(a){google.lm.push.apply(google.lm,a)};google.package main
lq=[];google.load=function(a,b,c){google.lq.push([[a],b,c])};google.loadAll=function(a,b){google.lq.push([a,b])};}).call(this);google.f={};var a=window.location,b=a.href.indexOf("#");if(0<=b){var c=a.href.substring(b+1);/(^|&)q=/.test(c)&&-1==c.indexOf("#")&&a.replace("/search?"+c.replace(/(^|&)fp=[^&]*/g,"")+"&cad=h")};</script><style>#gbar,#guser{font-size:13px;padding-top:1px !important;}#gbar{height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}@media all{.gb1{height:22px;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline !important}a.gb1,a.gb4{color:#00c !important}.gbi .gb4{color:#dd8e27 !important}.gbf .gb4{color:#900 !important}
</style><style>body,td,a,p,.h{font-family:arial,sans-serif}body{margin:0;overflow-y:scroll}#gog{padding:3px 8px 0}td{line-height:.8em}.gac_m td{line-height:17px}form{margin-bottom:20px}.h{color:#36c}.q{color:#00c}.ts td{padding:0}.ts{border-collapse:collapse}em{font-weight:bold;font-style:normal}.lst{height:25px;width:496px}.gsfi,.lst{font:18px arial,sans-serif}.gsfs{font:17px arial,sans-serif}.ds{display:inline-box;display:inline-block;margin:3px 0 4px;margin-left:4px}input{font-family:inherit}a.gb1,a.gb2,a.gb3,a.gb4{color:#11c !important}body{background:#fff;color:black}a{color:#11c;text-decoration:none}a:hover,a:active{text-decoration:underline}.fl a{color:#36c}a:visited{color:#551a8b}a.gb1,a.gb4{text-decoration:underline}a.gb3:hover{text-decoration:none}#ghead a.gb2:hover{color:#fff !important}.sblc{padding-top:5px}.sblc a{display:block;margin:2px 0;margin-left:13px;font-size:11px}.lsbb{background:#eee;border:solid 1px;border-color:#ccc package main
#999 #999 #ccc;height:30px}.lsbb{display:block}.ftl,#fll a{display:inline-block;margin:0 12px}.lsb{background:url(/images/nav_logo229.png) 0 -261px repeat-x;border:none;color:#000;cursor:pointer;height:30px;margin:0;outline:0;font:15px arial,sans-serif;vertical-align:top}.lsb:active{background:#ccc}.lst:focus{outline:none}</style><script nonce="SHnQTfU6Ib6WB7M7EohLwQ=="></script></head><body bgcolor="#fff"><script nonce="SHnQTfU6Ib6WB7M7EohLwQ==">(function(){var src='/images/nav_logo229.png';var iesg=false;document.body.onload = function(){window.n && window.n();if (document.images){new Image().src=src;}
if (!iesg){document.f&&document.f.q.focus();document.gbqf&&document.gbqf.q.focus();}
post:
 <!DOCTYPE html>
<!--[if IEMobile 7 ]> <html lang="en_US" class="no-js iem7"> <![endif]-->
<!--[if lt IE 7]> <html class="ie6 lt-ie10 lt-ie9 lt-ie8 lt-ie7 no-js" lang="en_US"> <![endif]-->
```

# 再挑戦
- 前日のエラーとは変化があった為、`http.Get`の部分をAPIを実施するURLに変えてみた
- 結果はダメ:frowning2:

```
$ go run ******_api.go 
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
main.keepLines(0xc000281400, 0x3c4, 0x3, 0x600, 0xc000281400)
        /home/******/go_sandbox/******_api.go:13 +0x10b
main.main()
        /home/******/go_sandbox/******_api.go:25 +0x141
exit status 2
```

- 表示されているエラー`runtime error: slice bounds out of range`で検索すると色々と例が事例がある様子
- 動きはしなかったが、昨日よりは変化があったので一歩前進としよう。エラー内容はまたあとで見ます