1. Goã®ã©ã€ãã©ãªãšã¯
Goã®ã©ã€ãã©ãªã¯Googleã«ããéçºãããé©æ°çãªèšèªã«ãã£ãŠãµããŒããããŠããŸããããã«ãããããã°ã©ããŒã¯ããçãæéã§é«å質ãªãœãããŠã§ã¢ãéçºã§ããããã«ãªããŸããã以äžã«Goã®ã©ã€ãã©ãªã«ã€ããŠããã®ç¹åŸŽãæŽå²ããããŠå©çšäºäŸã«ã€ããŠè§£èª¬ããŸãã
1.1 Goã®ã©ã€ãã©ãªã«ã€ããŠ
Goã¯Googleã«ãã£ãŠéçºããããªãŒãã³ãœãŒã¹ã®ããã°ã©ãã³ã°èšèªã§ãããã·ã³ãã«ããšå¹çæ§ãæ±ãããããœãããŠã§ã¢ã®éçºã«æé©ã§ããããã«å¯Ÿå¿ããGoã®ã©ã€ãã©ãªã¯ãGoã§æžãããã³ãŒãã®éãŸãã§ãæ¢ã«äœæãããæ©èœãåå©çšããããã«äœ¿çšãããŸãã
ã©ã€ãã©ãªã䜿ãããšã«ãããããã°ã©ããŒã¯äžããå šãŠãæžãå¿ èŠããªããéçºæéãå€§å¹ ã«ççž®ã§ããŸããGoã®ã©ã€ãã©ãªã¯ãGoã§ããã°ã©ãã³ã°ãå§ããéã«ããã®ãã¯ãã«ãªæ©èœãšè±å¯ãªå©äŸ¿æ§ããç¥èãæã£ãŠãããšåœ¹ç«ã€éèŠãªããŒã«ãšèšããŸãã
ãŸããGoã®ã©ã€ãã©ãªã¯ãããŒã¿ããŒã¹æ¥ç¶ãæå·åããããã¯ãŒãã³ã°ããã¹ããã¬ãŒã ã¯ãŒã¯ãªã©ãå¹ åºãå©çšç¯å²ã«ãããå€ãã®ã©ã€ãã©ãªããæãç«ã£ãŠããŸãããããã¯ãã¹ãŠGoã®å ¬åŒãµã€ãããå ¥æããããšãã§ãã容æã«çµã¿èŸŒãããšãã§ããŸãã
1.2 Goã®ã©ã€ãã©ãªã®ç¹åŸŽ
Goã®ã©ã€ãã©ãªãä»ã®èšèªã®ã©ã€ãã©ãªãšç°ãªãç¹ã¯ããã®åè¶ããããã©ãŒãã³ã¹ãšã·ã³ãã«ãã«ãããŸããéçåä»ããšã³ã³ãã€ã«ãããèšèªã§ããGoã¯ãå®è¡é床ãéåžžã«éããšããç¹åŸŽãæã£ãŠããŸãã
ãŸããGoã¯ã·ã³ãã«ãªææ³ãšæ§é ãæã£ãŠãããããåŠç¿ã³ã¹ããäœããŠæžã¿ãŸãããã®ã·ã³ãã«ãã«ãããGoã®ã©ã€ãã©ãªããŸããæå°éã®æ©èœããæããªããããéçºè ãå®éã«å¿ èŠãšããŠããæ©èœã ããçŽæ¥åŒã³åºãããšãå¯èœãšãªããŸãã
ããã«ãGoã®ã©ã€ãã©ãªã¯ä»ã®ã©ã€ãã©ãªãšã競åãããæ¢åã®ã©ã€ãã©ãªãšçµã¿åãããŠå©çšããããšãå¯èœã§ããç¬èªã®ã©ã€ãã©ãªãè¿œå ããããšãç°¡åã§ãäžåºŠã©ã€ãã©ãªãè¿œå ããã°å³åº§ã«å©çšã§ããŸãã
1.3 Goã®ã©ã€ãã©ãªã®æŽå²
Goãšãã®ã©ã€ãã©ãªã¯2007幎ã«Googleã®å éšãããžã§ã¯ããšããŠçãŸããŸããããã®ç®çã¯ããœãããŠã§ã¢éçºãã·ã³ãã«åããçç£æ§ãšèªã¿ããããåäžãããããšã§ããã
Goã®çºè¡šåŸãå€æ°ã®äŒæ¥ãéçºè ãGoã®ã©ã€ãã©ãªãå©çšããããã«ãã匷åãªã³ãã¥ããã£ã圢æãããŸããããã®çµæãä»æ¥ã§ã¯å€çš®å€æ§ãªã©ã€ãã©ãªãéçºãããå©çšããç¶ããŠããŸãã
Goã®ã©ã€ãã©ãªã®æŽå²ã¯ã€ãã«é²åãç¶ããŠããŸãããã®çµæãä»æ¥ã§ã¯Goã®ã©ã€ãã©ãªã¯Googleã ãã§ãªããå€ãã®äŒæ¥ãå人éçºè ã«ãã£ãŠéçºãã¡ã³ããã³ã¹ãè¡ãããŠããŸãã
1.4 Goã®ã©ã€ãã©ãªã®å©çšäºäŸ
Goã®ã©ã€ãã©ãªã¯å€ãã®æåäŒæ¥ã§ç©æ¥µçã«å°å ¥ãããŠããŸããäŸãã°ãGoogleãDropboxãDockerãKubernetesãªã©ã¯Goã®ããã©ãŒãã³ã¹ãšã·ã³ãã«ãã掻çšããŠããŸãã
å ·äœçãªå©çšäºäŸãšããŠãDockerã¯Goã®ã©ã€ãã©ãªã䜿çšããŠä»®æ³åæè¡ãéçºããKubernetesã¯Goãåºç€ãšããŠãã€ã¯ããµãŒãã¹ã管çããããã®ãã©ãããã©ãŒã ãæ§ç¯ããŠããŸãã
ãããã®å®äŸã¯ãGoã®ã©ã€ãã©ãªãããã«ãã¯ãã«ã§ããŸããã®å©çšç¯å²ãåºå€§ã§ãããã瀺ããŠããŸããä»åŸãåŒãç¶ããå€ãã®äŒæ¥ããããžã§ã¯ãã§å©çšãããããšãæåŸ ãããŸãã
2. Goã®ã©ã€ãã©ãªã®çšéå¥çŽ¹ä»
Goèšèªã¯èªäœãéåžžã«é«æ©èœã§æ±çšçãªããã°ã©ãã³ã°èšèªã§ãããç¹å®ã®ç®çã«ç¹åããéçºãè¡ãäžã§æ°å€ãã®ã©ã€ãã©ãªãååšããŸãããã®äžéšãããã§ã¯çŽ¹ä»ããŠãããŸãã
å ·äœçãªã©ã€ãã©ãªã®éžæã¯ãéçºããã¢ããªã±ãŒã·ã§ã³ãã·ã¹ãã ã®èŠä»¶ããããŠããªãèªèº«ã®ããã°ã©ãã³ã°ã¹ãã«ãçµéšã«å€§ããäŸåããŸãã
2.1 Webã¢ããªã±ãŒã·ã§ã³éçºçšã©ã€ãã©ãª
Goèšèªã¯Webã¢ããªã±ãŒã·ã§ã³ã®éçºã«ãããŠãåææ¥ç¶ãŠãŒã¶ãŒæ°ã®å€ãã·ã¹ãã ã§ãé«éã«åäœããããšãæ±ããããŸãããã®ããã«ã¯ãnet/httpãããã£ãšãåºæ¬çã§æåã§ãããã«ãŒãã£ã³ã°æ©èœã匷åãããgorilla/muxããããã¬ãŒã ã¯ãŒã¯ãšããŠå šäœçãªéçºå¹çã®åäžãå³ããRevelããªã©ãè¯ã䜿ãããŸãã
ãŸããGoã«ã¯ãã³ãã¬ãŒããšã³ãžã³ãçšæãããŠããããhtml/templateãã䜿çšããããšã§ãåçãªHTMLã³ã³ãã³ãã®çæãè¡ãããšãã§ããŸãã
ãããã®ã©ã€ãã©ãªãé©åã«çµã¿åãããããšã§ãå¹ççãã€é«æ§èœãªWebã¢ããªã±ãŒã·ã§ã³ã®éçºãå¯èœãšãªããŸãã
2.2 ããŒã¿åæçšã©ã€ãã©ãª
ããŒã¿åæãè¡ãäžã§ãå®éã®ããŒã¿æäœã«ã¯ãgonumãããdataframe-goããªã©ãçšããããŸãããããã®ã©ã€ãã©ãªã¯ãæè»ã§é«éãªæ°å€èšç®ãããŒã¿ãã¬ãŒã æäœãæäŸããããŒã¿åæãããç°¡åã«è¡ãããšãå¯èœã«ããŸãã
ãŸããå¯èŠåã«ã¯ãgo-echartsãããgonum/plotããªã©ãé©ããŠããŸãããããã®ã©ã€ãã©ãªã䜿çšããã°ãèŠãããã°ã©ãããã£ãŒããçæéã§äœæããããšãã§ããŸãã
èŠããã«ãGoèšèªã«ã¯å¹ççã«ããŒã¿åæãè¡ãããã®æ°å€ãã®ã©ã€ãã©ãªãååšããŠããŸãã
2.3 é«æ§èœã³ã³ãã¥ãŒãã£ã³ã°çšã©ã€ãã©ãª
é«æ§èœã³ã³ãã¥ãŒãã£ã³ã°åãã©ã€ãã©ãªãšããŠã¯ããgonumãããGorgoniaããããçšããããŸãããã®äºã€ã®ã©ã€ãã©ãªã¯ã倧èŠæš¡ãªæ°å€èšç®ãé«éã«åŠçããããšãå¯èœã«ããŸãã
ç¹ã«ãGorgoniaãã¯ããã£ãŒãã©ãŒãã³ã°ã®èšç®ã°ã©ããæ§ç¯ã»æé©åããå®è¡ããæ©èœãåããŠããŸãããã®ãããGoèšèªã§æ©æ¢°åŠç¿ã¢ã«ãŽãªãºã ãæ§ç¯ããéã«ã¯éåžžã«æåãªéžæè¢ãšãªã£ãŠããŸãã
ã€ãŸããGoèšèªã¯é«æ§èœã³ã³ãã¥ãŒãã£ã³ã°ã®äžçã§ãåãçºæ®ããç 究ãéçºã«å€§ãã«åœ¹ç«ã¡ãŸãã
2.4 ãããã¯ãŒã¯ããã°ã©ãã³ã°çšã©ã€ãã©ãª
ãããã¯ãŒã¯é¢é£ã®éçºãè¡ãéã«ã¯ããnetãããã±ãŒãžãåºã䜿ãããŸãããnetããšãã®ãµãããã±ãŒãžã«ã¯ãTCPãUDPçã®äžäœå±€ã®éä¿¡ã ãã§ãªããHTTPãFTPãšãã£ãäžäœå±€ã®éä¿¡ããµããŒããããŠããŸãã
ãŸãããgrpc-goãã¯ãGoogleãéçºããé«æ§èœãªãªã¢ãŒãããã·ãŒãžã£ã³ãŒã«ïŒRPCïŒãã¬ãŒã ã¯ãŒã¯ã§ãç°ãªãã·ã¹ãã ããµãŒãã¹éã§ã®å¹ççãªéä¿¡ãå®çŸããŸãã
ãã®ããã«ãGoèšèªã«ã¯ãæ§ã ãªã¬ãã«ã®ãããã¯ãŒã¯ããã°ã©ãã³ã°ããµããŒãããè±å¯ãªã©ã€ãã©ãªãæäŸãããŠããŸãã
3. Goã®äž»èŠãªã©ã€ãã©ãªã®è©³çŽ°è§£èª¬
3.1 Ginã«ã€ããŠ
Ginã¯ãGoèšèªã§éçºããããã¬ãŒã ã¯ãŒã¯ã§ãé«éã§æè»ãªã¹ã±ãŒã©ããªãã£ãåããŠããŸããGinã¯GitHubã§äººæ°ãéãã掻çºãªã³ãã¥ããã£ã«æ¯ããããŠããŸãã
ç¹åŸŽãšããŠã¯ããã«ããã¬ãã¯ã¹ã«ãŒãã£ã³ã°ãURLãã©ã¡ãŒã¿è§£æãã³ãŒãåå©çšã®ããã®äžéãŠã§ã¢ããã¹ããã¬ãŒã ã¯ãŒã¯ãªã©ããããŸãã
ãããŠãæ°ããªã¬ãã«ã®ããã©ãŒãã³ã¹ãè¿œæ±ããããã«ãGinã¯martiniããã€ã³ã¹ãã¬ãŒã·ã§ã³ãåŸãŠãããã®ã®ããã€ã¯ããã¬ãŒã ã¯ãŒã¯ã®å©ç¹ãä¿æãã€ã€äžèŠãªãªãŒããŒããããæé€ããŠããŸãã
3.2 GORMã«ã€ããŠ
GORMã¯ãGoã§æžãããéçºè ã«ãšã£ãŠéåžžã«æçšãªORMã©ã€ãã©ãªã§ããããã«ãããSQLããŒã¿ããŒã¹ãšããåããããããªãã ãã§ãªããã³ãŒãã®éãå€§å¹ ã«æžå°ãããããšãå¯èœã§ãã
äž»ãªæ©èœãšããŠã¯ãå šé¢çãªCRUDãé¢é£æ§ãšé£çµã®å¯Ÿå¿ããã©ã³ã¶ã¯ã·ã§ã³ãèªå移è¡ãSQLãã«ããã€ã³ããã¯ã¹ãšè€åããŒã®å¯Ÿå¿ãªã©ãæããããŸãã
GORMã¯éåžžã«é«æ©èœã§ãåæã«åŠç¿æ²ç·ãåªããŠããŸãããã®ãããåå¿è ããããã©ã³ãŸã§ã®éçºè ã«å¯ŸããŠéåžžã«èŠªåæ§ã®é«ãã©ã€ãã©ãªãšèšããŸãã
3.3 Revelã«ã€ããŠ
Revelã¯ãGoã§æžããããã«ã¹ã¿ãã¯ãªMVCïŒModel-View-ControllerïŒãã¬ãŒã ã¯ãŒã¯ã§ãããã®èªå·±å®çµåã®ç¹æ§ã«ãããRevelã¯ã·ã³ãã«ãªAPIãšåŒ·åãªæ©èœãæäŸããŸãã
ãã®ç¹æ§ãããRevelã¯ãã³ãã¬ãŒããšã³ãžã³ãã«ãŒãã£ã³ã°ããã©ã¡ãŒã¿ã®è§£æãããªããŒã·ã§ã³ãã»ãã·ã§ã³/ãã©ãã·ã¥ããã¹ãçšããŒãã¹ãªã©ã®äžççãªèŠæš¡ã®WebéçºèŠä»¶ãæºãããŸãã
ãŸããRevelã¯Goã®ç¹æ§ãå®å šã«æŽ»çšãããªãã¬ã¯ã·ã§ã³ãgoroutineãã€ã³ã¿ãã§ãŒã¹ãçµã¿èŸŒã¿ã®éçåæ€æ»çã䜿çšããŸããããã«ãããRevelã¯ãããã¯ã·ã§ã³æºååã®Webã¢ããªã±ãŒã·ã§ã³ã«éåžžã«é©ããŠããŸãã
3.4 Testifyã«ã€ããŠ
Testifyã¯ãGoã®æšæºã®”testing”ããã±ãŒãžãè£å®ããããã®ãè±å¯ãªæ©èœãæã£ãã©ã€ãã©ãªã§ãããã¹ãã®ã¢ãµãŒããã¢ãã¯ã®çæã容æã«ãããªã©ããã¹ããããèªã¿ãããã管çããããããããã®ããŒã«ãæäŸããŠããŸãã
Testifyã¯ãã¹ã€ãŒãã€ã³ã¿ãŒãã§ãŒã¹ãšã¢ãµãŒãããããŠã¢ãã¯ããã±ãŒãžã®3ã€ã®äž»èŠãªæ©èœããããŸãããããã¯ãããããå¿ èŠã«å¿ããŠäœ¿çšããããšãã§ããŸãã
éçºè ãæ°ãããã¹ããæžããã³ã«è»èŒªã®åçºæãããå¿ èŠããªãããã€çµ±äžãããæ¥çæšæºã®ãã¹ãã®äœæã管çãå®è¡ãå¯èœã«ããŸãããã®ãããGoã®éçºè ã«ãšã£ãŠTestifyã¯éåžžã«æçãªã©ã€ãã©ãªãšãªããŸãã
4. Goã®ã©ã€ãã©ãªã掻çšããéçºã®æµã
Goã®ã©ã€ãã©ãªã®é åãæ倧éã«æŽ»çšããããã«ã¯ãéçºå·¥çšå šäœãéããŠç確ãªäœ¿ãæ¹ãããªããã°ãªããŸããã以äžã§ã¯ãã©ã€ãã©ãªã®éžå®ããéçºããã¹ãããããŠãããã€ã»ã¡ã³ããã³ã¹ãŸã§ã®äžé£ã®æµããèŠãŠãããŸãããã
ãã®æµããææ¡ããããšã§ãåé¡è§£æ±ºã«åããé©åãªã©ã€ãã©ãªã®çšéã掻çšæ³ãæ確ã«ãªããããå¹ççãªéçºãå¯èœãšãªããŸãã
ããã«ãåã¹ãããã«æ²¿ã£ãŠå ·äœçãªæäœæ¹æ³ã瀺ããŠãããŸãã®ã§ãããããGoã®ã©ã€ãã©ãªã䜿ã£ãéçºãè¡ãæ¹ã¯ãã²åèã«ããŠã¿ãŠãã ããã
4.1 ãããžã§ã¯ãã®èšå®
ãŸãã¯ãããžã§ã¯ãã®èšå®ããå§ããŸãããã®ã¹ãããã§ãããžã§ã¯ãã®è©³çŽ°ãèšå®ããå¿ èŠãªã©ã€ãã©ãªã®æŠèŠãææ¡ããŸãã
ãããžã§ã¯ãã®æ§è³ªïŒWebã¢ããªã±ãŒã·ã§ã³ãããŒã¿è§£æããããã¯ãŒã¯ããã°ã©ãã³ã°ãªã©ïŒã«ãã£ãŠå¿ èŠãªã©ã€ãã©ãªã¯å€§ããç°ãªãããããã®æç¹ã§ã®å ·äœçãªç解ãåŸã®ã¹ãããã§ã®ã©ã€ãã©ãªã®éžå®ãšæŽ»çšã«åœ¹ç«ã¡ãŸãã
ãã®æ®µéã§ã¯ããããžã§ã¯ãã®ç®æšãæ確ã«å®çŸ©ãããã®äžã§ã©ã®ãããªæ©èœãå¿ èŠããªã©ãæ€èšããã®ããã€ã³ããšãªããŸãã
4.2 ã©ã€ãã©ãªã®éžå®ãšå°å ¥
次ã«ãå ·äœçãªã©ã€ãã©ãªã®éžå®ãè¡ããŸããããã§ã¯ãå ã®ã¹ãããã§ç«ãŠããããžã§ã¯ãã®ç®æšãå¿ èŠãªæ©èœãæºããããã®ã©ã€ãã©ãªãéžã³åºãäœæ¥ãšãªããŸãã
ããããã®ã©ã€ãã©ãªã¯ããã®æ©èœæ§ãããã©ãŒãã³ã¹ãããã«ã¯äœ¿ãããããªã©ã«éãããããŸãããã®ãããã©ã®ã©ã€ãã©ãªãéžã¶ãã¯ãããžã§ã¯ãã®æåã«çŽçµããŸãã
ã©ã€ãã©ãªã®éžå®ãçµãã£ãããå®éã«ãããžã§ã¯ãã«ã©ã€ãã©ãªãå°å ¥ããŸãããã®ããã»ã¹ã¯ãéžå®ããã©ã€ãã©ãªã®ããã¥ã¡ã³ããŒã·ã§ã³ãåèã«ããªããé²ããŠãããŸãã
4.3 ã³ãŒãã£ã³ã°ãšãã¹ã
ã©ã€ãã©ãªã®å°å ¥ãå®äºããããããããã¯ã³ãŒãã£ã³ã°ãšãã¹ããè¡ããŸããããã§ã¯ãéžå®ããã©ã€ãã©ãªã掻çšããã³ãŒããæžããŠãããŸãã
ãŸããã©ã€ãã©ãªãæäŸããæ©èœãæ£åžžã«åäœããŠãããã確èªããããã«ãé©åãªãã¹ãã³ãŒãã®äœæãè¡ããŸãããã®ã¹ãããã§ãã£ãããšã©ã€ãã©ãªã®æ©èœãææ¡ãã確èªãè¡ãããšãéèŠãšãªããŸãã
ã¡ãªã¿ã«ããã¹ãã§ã¯åäœãã¹ãã ãã§ãªããã©ã€ãã©ãªãçšããæã«çµæãæåŸ éãã«ãªããã®çµ±åãã¹ããéèŠã§ãã
4.4 ãããã€ãšã¡ã³ããã³ã¹
æåŸã«ãéçºããã¢ããªã±ãŒã·ã§ã³ããããã€ããŸãããã®æç¹ã§ãäœæããã³ãŒããå®éã«çšŒåãã䜿çšè ã«æäŸãããããšãšãªããŸãã
ãã®åŸã¯ã¡ã³ããã³ã¹ãè¡ããæ°ãã«å¿ èŠãªæ©èœã®è¿œå ããæ¢åã®ãã°ã®ä¿®æ£ãè¡ããŸãããã®äžã§ãã©ã€ãã©ãªãé©å®ã¢ããããŒããããããšããããŸãã
ãããã®ã¹ãããã¯ãGoã®ã©ã€ãã©ãªã掻çšããŠå¹ççãªéçºãè¡ãããã®åºæ¬çãªæµãã§ããéèŠãªã®ã¯ãããããã®ã¹ãããã§å¿ èŠãªããšãææ¡ããé©åãªã©ã€ãã©ãªã®éžå®ããå¹ççãªã³ãŒãã£ã³ã°ãé©åãªãã¹ãããããŠã¹ã ãŒãºãªãããã€ãšã¡ã³ããã³ã¹ãè¡ãããšã§ãã
5. Goã®ã©ã€ãã©ãªæŽ»çšäžã®æ³šæç¹
Goã®ã©ã€ãã©ãªã䜿çšã§ãããšãå€ãã®æ©èœãäœæã§ããå¹ççã«ããã°ã©ã ãå®æãããããšãã§ããŸããããããäžæ¹ã§ãããã®ã©ã€ãã©ãªã掻çšããäžã§æ³šæãã¹ãäºé ãããã€ãååšããŸãã
ããã§ããã®ç« ã§ã¯ãGoã®ã©ã€ãã©ãªã掻çšããéã®æ³šæç¹ãšããŠãããŒãžã§ã³ç®¡çã®éèŠæ§ããšã©ãŒãã³ããªã³ã°ã®çæç¹ããªãœãŒã¹ç®¡çãšããã©ãŒãã³ã¹æé©åããããŠã³ãã¥ããã£ãšããã¥ã¡ã³ããŒã·ã§ã³ã®æŽ»çšãªã©ã«ã€ããŠã話ãããŸãã
å®éã«ã©ã€ãã©ãªãå©çšããã·ãŒã³ãæ³åããªããã掻çšã®ãã³ããšãªãæ å ±ãèŠã€ããŠãããŸãããã
5.1 ããŒãžã§ã³ç®¡çã®éèŠæ§
Goã®ã©ã€ãã©ãªã䜿çšããéãæåã«çæãã¹ãã¯ããŒãžã§ã³ç®¡çã®éèŠæ§ã§ããGoã®ã©ã€ãã©ãªã¯ããã®éçºéçšã§æ©èœãè¿œå ãããããäžå ·åãä¿®æ£ããããããŠãããŒãžã§ã³ãäžããããšããããŸãã
ãã®ãããªç¶æ³ã«å¯Ÿå¿ãããããã©ã®ããŒãžã§ã³ã䜿çšããŠãããã確èªããå¿ èŠã«å¿ããŠããŒãžã§ã³ã¢ããããããšãéèŠã§ããç¹ã«ãã»ãã¥ãªãã£äžã®è匱æ§ãä¿®æ£ãããããŒãžã§ã³ã«ããã«å¯Ÿå¿ããããšã¯ãéåžžã«éèŠã ãšèšããŸãã
ãŸããäºææ§ããªãããŒãžã§ã³ã®éã§ã©ã€ãã©ãªã誀ã£ãŠæŽæ°ããªãããã«ããããã«ããããŒãžã§ã³ç®¡çã¯æ¬ ãããªãäœæ¥ãšãªããŸãã
5.2 ãšã©ãŒãã³ããªã³ã°ã®çæç¹
次ã«æ³šæãã¹ãã¯ããšã©ãŒãã³ããªã³ã°ã®çæç¹ã§ããã©ã€ãã©ãªã¯æ³šç®ãã¹ãæ©èœãæäŸããŸãããåæã«ãã®åäœã«å€±æããå¯èœæ§ãååšããŸãã
ãã®ãããããã°ã©ã ã®å®å®æ§ãä¿ã€ããã«ã¯ãã©ã€ãã©ãªããè¿ãããå¯èœæ§ã®ãããšã©ãŒãé©åã«ãã³ããªã³ã°ããããšãéèŠã§ãã ããã«ã¯ããšã©ãŒãçºçãããšãã®æ»ãå€ã®ãã§ãã¯ããé©åãªäŸå€åŠçãæ±ããããŸãã
ãããŠäœãããããšã©ãŒãã³ããªã³ã°ã®ã³ãŒãããã¡ããšæžãããšã§ãæªç¥ã®ãšã©ãŒãçºçãããšãã§ãå®å šã«å¯Ÿå¿ããããšãå¯èœãšãªããŸãã
5.3 ãªãœãŒã¹ç®¡çãšããã©ãŒãã³ã¹æé©å
ã©ã€ãã©ãªã®æŽ»çšã«ãããããäžã€ã®éèŠãªæ³šæç¹ããªãœãŒã¹ç®¡çãšããã©ãŒãã³ã¹æé©åã§ããGoã®ã©ã€ãã©ãªã¯ãè³æºã倧éã«äœ¿çšãããã®ããããŸãã
ãã®ãããå¹çè¯ããªãœãŒã¹ã管çããããšãæ±ããããŸããããã«ã¯ãäžèŠãªã€ã³ã¹ã¿ã³ã¹ã®è§£æŸãé©åãªã¹ã¬ããã®ç®¡çãå«ãŸããŸãã
ãŸããã©ã€ãã©ãªãããå¹æçã«äœ¿çšããããã«ã¯ãããã©ãŒãã³ã¹ã®æé©åãéèŠã§ããããã¯ãé©åãªã¢ã«ãŽãªãºã ã®éžæããå¿ èŠãªåŠçã®ã¿ãè¡ããªã©ã工倫ããããšãæ±ããããŸãã
5.4 ã³ãã¥ããã£ãšããã¥ã¡ã³ããŒã·ã§ã³ã®æŽ»çš
æåŸã«å¿ããŠã¯ãªããªãã®ããã³ãã¥ããã£ãšããã¥ã¡ã³ããŒã·ã§ã³ã®æŽ»çšã§ããGoã®ã©ã€ãã©ãªã¯è±å¯ãªããã¥ã¡ã³ããŒã·ã§ã³ãšæŽ»çºãªã³ãã¥ããã£ãæ¯ããŠããŸãã
ã©ã€ãã©ãªã®äœ¿çšæ¹æ³ããã¹ããã©ã¯ãã£ã¹ãç解ããããã«ãããã¥ã¡ã³ããŒã·ã§ã³ã®ç©æ¥µçãªå©çšãæšå¥šããŸãããŸããäžæç¹ãçåç¹ãããå Žåãããã解決ããããã«ã³ãã¥ããã£ã掻çšããããšãéèŠã§ãã
ç¹ã«ãã³ãã¥ããã£ã«åãåãããåã«ãæ¢ã«è§£æ±ºãããåé¡ãæ€çŽ¢ããããšã§ãæ©ãé²æãéããããšãã§ããŸãã
6. Goã®ã©ã€ãã©ãªã§å¯èœã«ãªãããš
Goã®ã©ã€ãã©ãªãçšãããšãèšå€§ãªç¯å²ã®ã¿ã¹ã¯ãå¹çããããã€å¹æçã«éæããããšãå¯èœã«ãªããŸããããã§ã¯ããŠã§ãã¢ããªã±ãŒã·ã§ã³éçºã®é«éåã倧éããŒã¿åŠçã®å®¹æåããªã¢ã«ã¿ã€ã éä¿¡ã®å®çŸããããŠé«åºŠãªãã¹ãèªååçã®ããŒããæ·±å ãããŠèŠãŠãããŸãããã
6.1 é«éãªãŠã§ãã¢ããªã±ãŒã·ã§ã³éçº
Goã®ã©ã€ãã©ãªã掻çšããããšã§ããŠã§ãã¢ããªã±ãŒã·ã§ã³éçºãããéã圢ã§é²è¡ãããããšãå¯èœã§ããEchoãGinãªã©ã®Goã®ãã¬ãŒã ã¯ãŒã¯ã䜿çšããããšã§ãã«ãŒãã£ã³ã°ãããã«ãŠã§ã¢æ©èœã®å®è£ ããããŠãã¹ãçã容æã«ãªããŸãã
ãŸããGoã¯ã³ã³ãã€ã«èšèªã®ãããããããããã€ããªã«ã³ã³ãã€ã«ãããå®è¡æã®ãªãŒããŒããããåæžããããšãå¯èœã§ããããã«ãããéçºããã»ã¹å šäœã®çç£æ§ãåäžããŸãã
å ããŠãGoã®ãŠã§ããã¬ãŒã ã¯ãŒã¯ã¯MVCïŒModel-View-ControllerïŒãã¿ãŒã³ãæ¡çšããŠãããã®ãå€ããããéçºè ã¯ã¢ããªã±ãŒã·ã§ã³ã®æ§é ãç¶æãããããããã«ã¯åå©çšå¯èœãªã³ãŒããæžãããšãã§ããŸãã
6.2 倧èŠæš¡ãªããŒã¿åŠç
倧èŠæš¡ãªããŒã¿ãåŠçããéã«ãGoã®ã©ã€ãã©ãªã¯åšåãçºæ®ããŸãããã®äžã§ããç¹ã«æ³šç®ãã¹ãã¯csvãjsonãªã©ãç°¡åã«æ±ããã©ã€ãã©ãªãã䞊ååŠçãè¡ãããã®GoRoutinesãChannelsãšããæ©èœã§ãã
倧èŠæš¡ããŒã¿ãçæéã§åŠçãã¹ããGoã§ã¯æ§ã ãªçš®é¡ã®ããŒã¿ãã©ãŒããããæ±ãããã®ã©ã€ãã©ãªãè±å¯ã«çšæãããŠããŸããããã«ãããããŒã¿ã®è§£æãæäœãä¿åãšãã£ãäœæ¥ãè¿ éã«è¡ããŸãã
ãŸããGoRoutinesãChannelsã䜿çšããããšã§ãè€æ°ã®ããŒã¿åŠçã¿ã¹ã¯ãåæã«è¡ãããšãã§ãã倧éã®ããŒã¿ãå¹ççã«åŠçããããšãå¯èœã«ãªããŸãã
6.3 ãªã¢ã«ã¿ã€ã éä¿¡ã®å®çŸ
Goã®ã©ã€ãã©ãªã®ãªãã«ã¯ããªã¢ã«ã¿ã€ã éä¿¡ã容æã«ãããã®ãååšããŸããç¹ã«WebSocketã®å®è£ ããã容æã«ããGorilla WebSocketãªã©ãåé«ãã§ãã
ãããã®ã©ã€ãã©ãªã䜿çšããããšã§ããã©ãŠã¶ãšãµãŒããŒéã®åæ¹åéä¿¡ãç°¡åã«äœæã§ããŸããããã«ããããªã¢ã«ã¿ã€ã ãã£ããã¢ããªãããªã¢ã«ã¿ã€ã ã®ããŒã¿æŽæ°ãè¡ãã¢ããªã±ãŒã·ã§ã³ã®å®è£ ã容æã«ãªããŸãã
ãŸããGoã¯ãã®æ§èœãšã¹ã±ãŒã©ããªãã£ããããªã¢ã«ã¿ã€ã éä¿¡ãå€æ°åŠçãããµãŒããŒéçºã«ãããŠãåªããéžæè¢ãšãããŠããŸãã
6.4 é«åºŠãªãã¹ãèªåå
Goã¯ã¢ããªã±ãŒã·ã§ã³ã®éçºã«ãããŠããã¹ãã®èªååã容æã«è¡ããããŒã«ãæäŸããŠããŸããç¹ã«testingããã±ãŒãžãhttp/httptestããã±ãŒãžãªã©ã¯ããŠããããã¹ããçµåãã¹ããAPIãã¹ããªã©ãå®è£ ããéã«éåžžã«äŸ¿å©ã§ãã
ãããã®ã©ã€ãã©ãªãçšãã°ãé«å質ãªãœãããŠã§ã¢éçºãç¶æãã€ã€ããã¹ãã®ã¹ããŒããšç²ŸåºŠãåäžãããããšãã§ããŸãããã¹ãã¯ããœãããŠã§ã¢éçºããã»ã¹ã«ãããéèŠãªèŠçŽ ã§ãããä¿¡é Œæ§ã®é«ãã¢ããªã±ãŒã·ã§ã³ãéçºããããã«ã¯æ¬ ãããŸããã
Goèšèªã«ããã¢ãã³ãªãœãããŠã§ã¢éçºãå®è·µãããªãããããã®ã©ã€ãã©ãªã®æŽ»çšã¯å¿ é ãšèšããã§ããããããããããŸã䜿ãããªãããšã§ã匷åãã€å¹ççãªã¢ããªã±ãŒã·ã§ã³éçºãå¯èœã«ãªããŸãã