You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
è¨å¿µãã¹ãZenn1æ稿ç®ãGoã«ã¤ãã¦ã話ãããã¨æãã¾ãã Goã§ã®ã¨ã©ã¼ãã³ããªã³ã°ã£ã¦ããããæ©ã¾ãªãï¼ æè¿Goã«è§¦ããæ©ä¼ãå¢ãã¦ããã®ã§ãããJVMè¨èªãã¡ã¤ã³ã ã£ã人éãããã㨠ãªããªãã¨ã£ã¤ãã«ããã¨ãããå¤ããæ £ããªãæ¥ã ã§ãããã®ã²ã¨ã¤ãã¨ã©ã¼ãã³ããªã³ã°ã§ãã ç¹ã«ãAPIå®è£ ãªã©ã§ããã¡ã¤ã³å±¤ã§çºçããã¨ã©ã¼ãã³ã³ããã¼ã©å±¤ã§ã©ããã³ããªã³ã°ãããããª...ãã¨ããã ããã§èªåãªãã«ããããä¸çªãã£ããããããªãã¨æãã·ã°ããã£ãç´¹ä»ãã¾ãã ã¾ãã¯ãããããã¿ã¼ã³ func (c *booksController) Update(ctx *gin.Context) { req := &BooksApiUpdateRequest{} if err := ctx.ShouldBind(req); err != nil { // ãªã¯ã¨ã¹ããä¸æ£ãªãBadRequ
Goã®è»½éWebã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯(Echo, Gin)ã®ãã£ã¬ã¯ããªæ§æ Golangã®è»½éWebã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã§ãããEchoãGinã使ãã¨Ruby on Railsã®ããã«ãã£ã¬ã¯ããªæ§æãç¹ã«æ±ºã¾ã£ã¦ããªããããã©ã®ããã«ããã°å¹ççã«éçºã§ããã®ãæ©ã¿ã¾ãã ããããæè¿ããã¤ãGinãEchoã使ã£ã¦APIãµã¼ããä½æãããªãã¨ãªããã£ã¬ã¯ããªæ§æã決ã¾ã£ã¦ããã®ã§ãå ±æãã¾ãã 以ä¸ã®ãªãã¸ããªã¯å¾è¿°ããèªåãªãã¸ããªçæã³ãã³ãã§çæãããããã¸ã§ã¯ãã®éå½¢ã§ãã ããã«ã¤ãã¦èª¬æããã¦ããã¾ãã ã¾ããã£ã¬ã¯ããªãæ¨æ§é ã§è¡¨ç¤ºããã¨ä»¥ä¸ã®ããã«ãªãã¾ãã âââ README.md âââ config â  âââ config.go â  âââ environments â  âââ development.yml â  âââ
æ¬æ¸ã¯ãGoè¨èªã§åæ£ãµã¼ãã¹ãæ§ç¯ããæ¹æ³ã解説ããæ¸ç±ã§ããåæ£ãµã¼ãã¹ã®æ¦è¦ã¨åºæ¬ã解説ããè¨è¨ãéçºãããã³ãããã¤ããæ¹æ³ãã³ã¼ãã使ã£ã¦ãã³ãºãªã³å½¢å¼ã§å¦ã³ã¾ããã¯ããã«ãã¹ãã¬ã¼ã¸ã¬ã¤ã¤ã®æ§ç¯ã¨ãã¼ã¿æ§é ã®å®ç¾©ãè¡ããgRPCãç¨ãã¦APIãå®ç¾©ãããµã¼ãã¹ããããã¯ã¼ã¯ä¸ã§åä½ãããæ¹æ³ã説æãã¾ããããã¦ãµã¼ãã¹ãåæ£ããã¦ãå¯ç¨æ§ãèé害æ§ãæ¡å¼µæ§ãå®ç¾ããæ¹æ³ã解説ããæ¬çªç°å¢ã®Kubernetesã¸ãããã¤ããæ¹æ³ãå¦ã³ã¾ãã [æ¬æ¸ã®æ£èª¤è¡¨] æ¬æ¸ã¸ã®æ¨è¦ã®è¨è ã¯ãã㫠第Ié¨ãããå§ãã¾ããã 1ç« ãã¬ããGo 1.1ãHTTPãã¼ã¹ã®JSONãµã¼ãã¹ã®åæ£ã·ã¹ãã ã¸ã®é©åæ§ 1.2ãããã¸ã§ã¯ãã®æºå 1.3ãã³ããããã°ã®ãããã¿ã¤ãã®ä½æ 1.4ãHTTPãã¼ã¹ã®JSONãµã¼ãã®æ§ç¯ 1.5ããµã¼ãã®å®è¡ 1.6ãAPIã®ãã¹ã 1.7ãå¦ãã ã㨠2ç«
調ã¹ããã¨æã£ããã£ããã¯ãgolang ã§ã¯ä»¥ä¸ã®ããã« ãã¼ã«ã«å¤æ°ã®ã¢ãã¬ã¹ãæ»ãå¤ã¨ãã¦ãåé¡ãªãã¨ãããã¨ã package main import ( "fmt" ) type Animal struct { Name string Age int } func main() { animal := allocAnimal() fmt.Printf("allocate animal structure %p", animal) } func allocAnimal() *Animal { return &Animal{} } C/C++ ã§ã¯ãã¼ã«ã«å¤æ°ã®ãã¤ã³ã¿ãæ»ãå¤ã¨ããå ´åã ã¹ã¿ãã¯é åã®ãã¤ã³ã¿ãé¢æ°å¤ã«æ¸¡ãã¦ãã¾ããããã³ã³ãã¤ã«æç¹ã§è¦åã表示ããã¾ã (ãªãã¨ã©ã¼ã«ããªã) å®è¡æã«ã¯ææªãã»ã°ã¡ã³ãã¼ã·ã§ã³ãã©ã¼ã«ãã§è½ã¡ã¾ã ãã®ãããmalloc ã n
ã¯ããã« Goã¯ã§ããã ãåé·ãªæ©è½ã»ãããå¢ãããã«å¿ç¨ã®å¹ãã·ã³ãã«ã§å¼·åãªæ©è½ã»ããã«çµãè¾¼ãã è¨è¨ã§ãããã¨ãç®æããè¨èªå¦çç³»ã§ãããªã®ã§ãªãããªæ©è½ãæã¤è¨èªå¦çç³»çµé¨è ããããã¨ããããã®ããªãï¼ããæããã¨æãã¾ãã ããããGoã®éçºè ãã¡ã¯ä»ã®è¨èªå¦çç³»ã«ããæ©è½ã ããGoã«ãæ¡ç¨ãããã¨ã¯ä¸åèãã¾ãããããã¾ã§å¤§ããªã²ã¤ã³ï¼ãã¡ãªãããã¡ãªããã大ããä¸åãï¼ã示ãããã¾ã§ã¯æ¡ç¨ãã¾ãããç¹ã«è¨èªä»æ§ã«ã¤ãã¦ã¯ããå¤æ´ãå«ãå¾åãããã¾ãããGo1ã®ç´æãã¨ãããã®ããããGo1.0åãã«æ¸ãããã³ã¼ãã¯Go1.xã§ãåããããã¯æ©æ¢°çã«ã³ã¼ãã«ããããå½ã¦ããã¨ã§ç§»è¡å¯è½ã«ããã¨ãããã¨ããã£ã¨å®ã£ã¦ãã¾ãï¼ç´ï¼å¹´ï¼ï¼ã æè¿ã«ãªãGo2ãããã¼ã¶ã«ãããããæ¸ããããããã®ææ¡ã®ãã¡è¨èªä»æ§ã«é¢ãããã®ã¯æçµçã«ï¼ãï¼åã«çµãè¾¼ã¾ãé 次æ¡ç¨ããã¦ããã¨ããè¨ç»ã§
TL;DR ããã¾ã§ Go 1.13 ããç»å ´ãã errors.As ã®ä½¿ãæããã¾ãè¯ãããããªãã£ãã®ã§ããï¼ å ¨ã¦ã®çãã¯å ¬å¼ Doc ã«ããã¾ããï¼ In the simplest case, the errors.Is function behaves like a comparison to a sentinel error, and the errors.As function behaves like a type assertion. errors.Is: ç¹å®ã®ã¨ã©ã¼ã¨ã®æ¯è¼ errors.As: ã¨ã©ã¼ã«å¯¾ããåã¢ãµã¼ã·ã§ã³ ããã§ã¯å®ä¾ããã¨ã«ç解ãæ·±ãã¦ããããã¨æãã¾ãï¼ å®ä¾ error.Is errors.Isã¯ããã¨ã©ã¼ãç¹å®ã®ã¨ã©ã¼ã Wrap ãããã®ããå¤å¥ããããã®ãã®ã§ãï¼ import ( "fmt" "errors" ) ErrFoo :=
Goã®ãã¹ãã«ã¤ãã¦ããã¤ãã¾ã¨ããæ¸ãã¦ããã Goã®testãç解ãã in 2018 #go Goã®testãç解ãã in 2019 触ããã®ãå¿ãã¦ããhttptestããã±ã¼ã¸ã«ã¤ãã¦ã¾ã¨ããã https://golang.org/pkg/net/http/httptest/ TL;DR net/http/httptestããã±ã¼ã¸ https://golang.org/pkg/net/http/httptest/ net/http/httptestããã±ã¼ã¸ã¯ãµã¼ã/ã¯ã©ã¤ã¢ã³ã両æ¹ã®HTTPå¨ãã®ãã¹ãã§ä½¿ã ãµã¼ãã®HTTPãã³ãã©ã¼ã®ãã¹ããæ¸ãã¨ã https://golang.org/pkg/net/http/httptest/#NewRequest https://golang.org/pkg/net/http/httptest/#NewRecorder ããã¼
ããã«ã¡ã¯ããã¡ãã¯Linc'wellã¢ããã³ãã«ã¬ã³ãã¼ã®1æ¥ç®ã§ãã çããã¯DBã«å¯¾ãã¦æ¸ãè¾¼ã¿ãçºçããé¢æ°ã®ãã¹ããã©ã®ããã«è¡ããã¦ããã§ããããï¼ ç§ã¯golangåå¿è ã©ããããµã¼ããµã¤ãåå¿è ãªã®ã§ãæé©è§£ãå ¨ããã£ã¦åãããªãã£ãã®ã§ããããããã調ã¹ãæ«ããããªæãã§ç¨æããã¨è¯ããããã¨ãããã¹ãç°å¢ã»æ¸ãæ¹ã«è½ã¡çããã®ã§ãããããã«è¨ãã¾ãã åãæ©ã¿ãæã£ãæ¹ã«å¤æåºæºãæä¾ã§ãããããªè¨äºã«ãªã£ã¦ããã¨å¬ããã§ãã(ããããã°å¼·ã人ããã®ãã£ã¼ãããã¯å¾ ã£ã¦ã¾ã) ã¯ããã«: ã©ããªãã¹ããæ¸ãããã®ã ã¯ããã«è¦ä»¶ãã¯ãªã¢ã«ããããã«ã©ããªãã¹ããæ¸ãããã®ãã®å ·ä½ä¾ãæ¸ãã¾ãã ãã ä»ç§ã¯ECãµã¤ãã®éçºããã¦ãã¦ããã®ä¸ã§å®æè³¼å ¥ã®ä»çµã¿ãä½ã£ã¦ãã¾ãã å®æè³¼å ¥ã¯ã¦ã¼ã¶ãå®æè³¼å ¥ãç³ãè¾¼ãã éã«ã次ã«ã©ã®æ¥ä»ã«ã©ããªååãè³¼å ¥ããã®ããã¨ãããã¼ã¿ã
ã¡ã«ã㤠ã¨ãã¹ãã¼ããã¼ã ã®@tenntennã§ããæ¬ç¨¿ã¯ Merpay Tech Openness Month ã®11æ¥ç®ã®è¨äºã§ãã ãããã°ã©ãã³ã°è¨èªGoå®å ¨å ¥éãã®æééå®å ¬éã®ãç¥ããã§ãæ¸ããããã«ãã¡ã«ãã¤ã§ã¯ã社å¤ã®æ¹åãã«Gopheréå ´ã¨ããä½ç³»çã«Goãå¦ã¹ãå ´ãç¡åã§æä¾ãã¦ãã¾ãããGoã®æ®åãç®çã«ããã¾ã§ã«8åéå¬ã100人以ä¸ã®æ¹ã«åå ãã¦ããã ãã¾ããã ã¾ããGopheréå ´ã®åç»ãè³æã¯Gopheréå ´ èªç¿å®¤ã¨ãã¦èª°ã§ãå©ç¨ã§ããããã«ãªã£ã¦ãããç¾æç¹ã§300å以ä¸ã®æ¹ãå©ç¨ããã¦ãã¾ãã Gopheréå ´ã®è³æã®ãã¼ã¹ã«ãªã£ã¦ãããããã°ã©ãã³ã°è¨èªGoå®å ¨å ¥éãã¯ã2020å¹´7æ31æ¥ã¾ã§ã®éå®å ¬éã«ãªã£ã¦ãã¾ããããæ¬æ¥ããå ¬éæéãæ¤å»ããå®å ¨å ¬éãããã¨ã«ãªãã¾ããã ã¾ããæ¬æ¥8æ31æ¥ããå§ã¾ããOnline Summer Int
ãããããã¤ãå¤ãä»£å ¥ãããã³ã«æ°ããcontextãçæãããã ãªã®ã§ãä¹±æ´ã«å¤ãä¸æ¸ããªãéãã¯ãã¾ãç¶æ ãæ°ã«ããªãã¦ããã Timeoutã¨Cancel func WithCancel func WithDeadline func WithTimeout ã¯ãã£ã³ã»ã«ãåãæ±ãã WithTimeout, WithDeadline ã¯ç¹å®æéã«ãªã£ãã¿ã¤ãã³ã°ã§ãã£ã³ã»ã«ãããã å¼æ°ã§æå®ã®ä»æ¹ã ä½ç§å¾ãã¨æå»æå®ããªã®ãéãã ãã å®éã«WithTimeoutã®ä¸èº«ã¯ WithDeadlineãå¼ãã§ããã ãã WithTimeout, WithDeadline æå®ããæéå¾ã«ãã£ã³ã»ã«ã¤ãã³ããèµ·ããã // 5ç§ãããå¦ç func heavyFunc(ctx context.Context) { time.Sleep(5 * time.Second) } func
I have a struct type with a *int64 field. type SomeType struct { SomeField *int64 } At some point in my code, I want to declare a literal of this (say, when I know said value should be 0, or pointing to a 0, you know what I mean) instance := SomeType{ SomeField: &0, } ...except this doesn't work ./main.go:xx: cannot use &0 (type *int) as type *int64 in field value So I try this instance := SomeTyp
sort.Sliceã¨sort.SliceStableã使ç¨ãã¦Goã®SliceãSortãã¦ã¿ãã æ¬è¨äºã®ã³ã¼ãå ¨ä½ã¯ä»¥ä¸ã https://play.golang.org/p/Lnj8kAwWxyy å®å®ã½ã¼ã(stable sort)ã¨ã¯ ã¾ãsortã¯å®å®ã½ã¼ããã©ããã§æåãç°ãªã å®å®ã½ã¼ã(stable sort)ã«ã¤ãã¦ã¯ä»¥ä¸ãããããããã®ã§å¼ç¨ããã¦ããã ããã å®å®ã½ã¼ãï¼ããã¦ãã½ã¼ããstable sortï¼ã¨ã¯ãã½ã¼ãï¼ä¸¦ã³æ¿ãï¼ã®ã¢ã«ã´ãªãºã ã®ãã¡ãåçãªãã¼ã¿ã®ã½ã¼ãåã®é åºããã½ã¼ãå¾ãä¿åããããã®ããããã¤ã¾ããã½ã¼ãéä¸ã®åç¶æ ã«ããã¦ã常ã«é ä½ã®ä½ç½®é¢ä¿ãä¿ã£ã¦ãããã¨ãããã ãã¨ãã°ãå¦ççªå·é ã«æ´åæ¸ã¿ã®å¦çãã¼ã¿ãããã¹ãã®ç¹æ°é ã§å®å®ã½ã¼ããç¨ãã¦ä¸¦ã¹æ¿ããã¨ããã½ã¼ãå¾ã®ãã¼ã¿ã«ããã¦ãåãç¹æ°ã®å¦çã¯å¦ççªå·é ã§ä¸¦ã¶ããã«ãªã£ã¦ãã
Goåå¿è ããã£ã¦ãã¾ããã¡ãªãããªãæ¹ããããã¨ãæ¸ãåºãã¦ã¿ã¾ããã æ å ±æ¤ç´¢ãç°å¢æ§ç¯ golang.jpãè¦ã«è¡ã£ã¦ãã¾ã Golangï¼ãã¼ãããï¼ã¨å¼ãã§ãã¾ã(by hogedigo) depãææ°æ¨å¥¨ã®ããã±ã¼ã¸ããã¼ã¸ã£ã ã¨åéããã(Goæ¨æºã®ãgo modãã使ãã) ãGOï¼ï¼ï¼ãç°å¢å¤æ°ãç解ããã«è¨å®ãã¾ããï¼ããããªãå ´åã¯ä¸åè¨å®ããªãã®ãæ£ããï¼ ããã£ã±ãªããgvm,gobrew,goenvãªã©ã®ãã«ããã¼ã¸ã§ã³ã®ããã¼ã¸ã£ãå ¥ãããã¨ãã¦ã¨ãã£ã¿é£æºç°å¢æ§ç¯ã«å¤±æãã ï¼è¤æ°ãã¼ã¸ã§ã³ã®Goã®éç¨ã¯æ¢ã«æ¨æºã®Goã ãã§ã§ããããã«ãªã£ã¦ããï¼ ã¨ãã£ã¿ã«goimportsãgolintãè¨å®ãå¿ãã OSã®ããã±ã¼ã¸ããã¼ã¸ã£ã¾ããã§å¤ãGoãgccgoãã¤ã³ã¹ãã¼ã«ãã¦ãã¾ã ã¨ã©ã¼ãã³ããªã³ã°å¨ã errå¤æ°åã®ããªã¨ã¼ã·ã§ã³ãå¢ãããããï¼ã»ã¨ã
2. èªå·±ç´¹ä» â¢ æ²³æ¬ æ³°å @yasi_life â @kwmt27 ⢠ç§ã¨Goè¨èªã¨ã®é¢ãã ⢠2011å¹´ã®DevQuizã§åãã¦è§¦ã£ã ⢠2012å¹´1æã®Goè¨èªåå¼·ä¼ã«åå ⢠2012å¹´4æã®æ±æµ·GTUGããã®GAE åå¼·ä¼ã§Goã使ã£ã 3. èªå·±ç´¹ä» ⢠æè¿ã§ã¯å ¬å¼ãµã¤ã㮠⢠Writing Web Applications ⢠Go Slices ã翻訳ãã¦ã¿ããã https://github.com/ kwmt/golangwiki/wiki
å¤§å¹ ã«å çãã¦æ¹è¨ç¬¬äºçã¨ãã¾ãã 2015-01-11 ã¾ããã Go ã競æããã°ã©ãã³ã°ã«åãã¦ãããã©ããã®è°è«ã¯å¥ã¨ãã¦ï¼ ã¯ãã㫠競æããã°ã©ãã³ã°ã§ã¯ï¼æ¨æºå ¥åããã¹ãã¼ã¹ã¾ãã¯æ¹è¡ã§åºåããã大éã®æ°å¤ãæååãèªã¿è¾¼ããã¨ãããããã¾ã(ãã¨ãã°ï¼AtCoder Begineer Contest #002 ã®å ¥å ãªã©)ï¼C++ ãªã©ç«¶æããã°ã©ãã³ã°ã®ã¡ã¸ã£ã¼è¨èªã®å ´åã¯ï¼ãã¦ãã¦ãèç©ããã¦ãã¦ï¼Google å çã«èãã°ãããã§ãæãã¦ããããã®ã§ããï¼ä¾ï¼ï¼Go ã¨ãªãã¨ããã¯ããã¾ããï¼ããããï¼ä¾ã«æãã AtCoder ã§ã Go 使ããªãã§ããï¼åç 2014å¹´6æ14æ¥ç¾å¨; 2015å¹´1æ11æ¥å確èªï¼ï¼ ããã§ï¼godoc ãè¦ãªãã使ããããªãã®ãæ¢ãã¦ã¿ã¾ããï¼æ³å®ã¨ãã¦ã¯ C++ ã® cin >> ã¨ã Java ã® java.util.Sc
èªè 対象 Goã®åºæ¬çãªææ³ãç¥ã£ã¦ãã ãªã¯ã¨ã¹ããããã¨ãé¢æ°ãå®è¡ãããä»çµã¿ãç¥ããã Goã®WebApplicationFrameworkã使ãããªããã ãªãããã®ãï¼ æ®æ®µãWebã¢ããªã±ã¼ã·ã§ã³ãä½ã£ã¦ããã¨ãªã¯ã¨ã¹ããããã¨å¯¾å¿ãããã¹ã«å¿ãã¦é¢æ°ãå®è¡ãããå¿ è¦ãããã¾ããã WAFã使ã£ã¦ããã¨å é¨ã§ã©ã®ãããªå¦çãããã¦ãããªã£ã¦ããã®ãç¥ããã«åããã¦ãã¾ãã¾ãã ããããæ£ããWebã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã使ãããªãã«ã¯ãå é¨ã®å®è£ ã«ã¤ãã¦ã®ç解ãå¿ è¦ãªã®ã§ããã®æ©ä¼ã«net/httpããã±ã¼ã¸ã®Documentãè¦ãªããããªã¯ã¨ã¹ããããã¨é¢æ°ãå®è¡ãããã¾ã§ã®ä»çµã¿ã調ã¹ã¾ãããç¹ã«ãhttp.Handleã¨ãhttp.HandleFuncã¨ãä¼¼ããããªååããã£ã¦ä¸è¦ããããããã¾ãããDocumentã«ç°¡æ½ã«èª¬æããã£ãã®ã§ããã¾ã§è¦å´ãããã¨ãª
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}