ã¿ã¤ãã«ã®éãã§ããGo 㯠LL çã«ä½¿ãããã¨ã¯ããç³ãã¾ãããããããæèã§ä½¿ã£ã¦ãã㨠REPL çãªãã¨ããããã¨ãã«å°ããã¡ã§ããããããã§ä½ãã¾ãããgoreãããååã§ããã
以ä¸ã®ã¹ã¯ãªã¼ã³ãã£ã¹ãã§ã ãããã®é°å²æ°ããå¯ãä¸ããã
ï¼ã¹ã¯ãªã¼ã³ãã£ã¹ã㯠cho45/KeyCast ã使ã£ã¦æ®å½±ãã¾ããï¼
ç¹å¾´
gore ã®ç¹å¾´ã¯ä»¥ä¸ã®éãã§ãã
- ã©ã¤ã³ã¨ãã£ã¿ã¨å±¥æ´
- è¤æ°è¡å ¥å
- ããã±ã¼ã¸ã®ã¤ã³ãã¼ããè£å®ã¤ã
- å¼ããã³æãå®è¡å¯è½
- ã³ã¼ãè£å®ï¼nsf/gocode ãå©ç¨ï¼
- ããªãã£ããªã³ãï¼k0kubun/pp ã davecgh/go-spew ãããããï¼
- ããã¥ã¡ã³ããå¼ããï¼godoc ãå¿ è¦ï¼
以ä¸ã®ããã«ãé常ã«ä¾¿å©ãªãã®ã«ãªã£ã¦ããã¾ããããããã®ç¨åº¦ REPL ã«ã¯å½ç¶ãã£ã¦ã»ããæ©è½ã ã¨ãè¨ããã
ã¤ã³ã¹ãã¼ã«
å©ç¨ã«ã¯ Go æ¬ä½ãå¿ è¦ãªããããã¤ããªã®é å¸ã¯ãã¦ãã¾ããã
go get github.com/motemen/gore
å®å
¨ãªæ©è½ã®ããã«ã以ä¸ã®ã©ã¤ãã©ãªãå¥é go get
ãã¦ãããã¨ããè¦ããã¾ãã
go get github.com/nsf/gocode # å ¥åè£å®ã« go get github.com/k0kubun/pp # ããªãã£ããªã³ãã« go get golang.org/x/tools/cmd/godoc # ããã¥ã¡ã³ãã«
使ãæ¹ã»æ©è½
gore
ã§èµ·åããã¨ãããã³ããã表示ããã¾ããGo ã®å¼ãæãå
¥åãã¦ãã ãããå
¥åãããå
容ãå¤ãè¿ãå¼ãå¤æ°ã®ä»£å
¥ã¨ãªãæã§ãã£ãå ´åã«ã¯ããããªã«å¤ãå°åããã¾ãã
gore> n := 1 1 gore> n+1 2
å
¥åããã¾ã解æã§ããªãã£ãã¨ãã¯ããã³ããã .....
ã¨ãªããç¶ãã¦å
¥åã§ãã¾ããEOFï¼^D
ï¼ã§ãã£ã³ã»ã«ãã¾ãã
gore> even := func(n int) bool { ..... return n % 2 == 0 ..... } func(int) bool {...} gore> even(4) true
Go ã®ã³ã¼ãã§ã¯ãªãæ示ã¯ãã³ãã³ã§å§ã¾ãã³ãã³ãã§å
¥åã§ãã¾ãã:help
ã§ãã¹ã¦ã®ã³ãã³ããä¸è¦§ã§ãã¾ããããã使ãã®ã¯ããã±ã¼ã¸ã®ã¤ã³ãã¼ããè¡ã :import
ã§ãããã
gore> :import strings gore> strings.TrimSpace(" foo ") "foo"
ã¾ã :write
ã³ãã³ãã§ãREPL ã»ãã·ã§ã³ã§çæãããã³ã¼ãããã¡ã¤ã«ã«ä¿åãããã¨ãã§ãã¾ãã
ã³ã¼ãè£å®
ã¨ãã£ã¿ã§ Go ãæ¸ãã¦ãã人㯠gocode ãã¤ã³ã¹ãã¼ã«ãã¦ãããã¨ã¨æãã¾ãããgore ããããå©ç¨ãã¦ã³ã¼ãè£å®ãè¡ãã¾ããã¹ã¯ãªã¼ã³ãã£ã¹ãã«ããããã«ãé©å½ãªã¨ãã㧠Tab
ãã¼ãæ¼ããã¨ã§ã³ã¼ãã®è£å®ãããæãã«ãªããã¾ãã
ããªãã£ããªã³ã
pp ã spew ãã¤ã³ãã¼ãã§ããç°å¢ã§ããã°ãããããå©ç¨ãã¦å¤ã®è¡¨ç¤ºããããªãã¾ãããªããã° fmt.Printf("%#v", ...)
ã«ãã©ã¼ã«ããã¯ãã¾ãã
ããã¥ã¡ã³ããå¼ã
:doc
ã³ãã³ãã§ããã¥ã¡ã³ããå¼ãã¾ããååã ãã§ãªãåãè¦ã¦ãã®ã§ãããå¤æ°ã®ã¡ã½ããããããã¥ã¡ã³ããå¼ãã¨ãããã¨ãã§ãã¾ããgodoc ã³ãã³ããå¿
è¦ã
gore> :import encoding/json gore> :doc json.Decoder ï¼godoc encoding/json Decoderï¼ gore> d := json.NewDecoder(nil) ... gore> :doc d.Decode ï¼godoc encoding/json Decodeï¼
ä»ã® REPL å®è£ ã¨ã®æ¯è¼
Go ã® REPL ãä½ããã¨ãã試ã¿ã¯äººé¡å ±éã®ããã§ããã§ã«ããã¤ãã®å®è£ ãåå¨ãã¦ãã¾ã:
- go-repl
- rango
- igo
- play.golang.org ï¼ãã¾ãï¼
以ä¸ããããã«ã®æ©è½ã«ã¤ãã¦ç°¡åã« gore ã¨æ¯è¼ããã表ã§ãã
å®è£ | å¤ã®è¡¨ç¤º | ã¤ã³ãã¼ã | æã®å ¥å | ã¢ã³ã㥠| è¡ç·¨é | è¤æ°è¡å ¥å |
---|---|---|---|---|---|---|
gore | â | â | â | â | â | |
go-repl | â | â | â | |||
rango | â | â | â | |||
igo | â | â | â | |||
play.golang.org | â | â | â | â |
è£è¶³
- ãå¤ã®è¡¨ç¤ºãã¨ã¯
1 + 1
ãªã©ã¨å ¥åããã¨ãã«ãã®å¤ã表示ã§ãããã¨ã対å¿ãã¦ããªãå®è£ ã§ã¯ "1 + 1 evaluated but not used" ãªã©ã®ã¨ã©ã¼ã表示ãããfmt.Println(1 + 1)
ãªã©ã¨ããªããã°ããã¾ããã - ã³ã¼ãè£å®ãè²ä»ãããªãã£ããªã³ãã«å¯¾å¿ãã¦ããã®ã¯ gore ã®ã¿ã§ãã
注æç¹
- REPL ã¨ããã¤ã¤å®ã¯è£ã§ã¯ããã¾ã§ã®å
¥åãé çªã«å®è¡ããã½ã¼ã¹ã³ã¼ããçæãã¦
go run
ãã¦ããã ããªã®ã§ãã©ããã®æç¹ã§è©ä¾¡ã«æéã®ãããã³ã¼ããå ¥åããã¨ããã®å¾ã®å ¥åã®è©ä¾¡ã«ãæéããããããã«ãªãã¾ãã
以ä¸
ç´¹ä»ããæ©è½ã®ã»ãã«ãGo ã§ã¯ã¤ã³ãã¼ãããããã±ã¼ã¸ãå©ç¨ããã¦ããªãã£ããæªä½¿ç¨ã®å¤æ°ããã£ããããã¨ã¨ã©ã¼ã«ãªã件ã®åé¿ãªã©ãå¿«é©ãª REPL ä½é¨ã®ããã«ç´°ãã調æ´ãã¦ãã¾ããã©ãããå©ç¨ä¸ããã
ãã¤ãéãã³ã¼ã㯠GitHub ä¸ã«ããã¾ããä¸å¯©ãªæåããã£ãã Issues ãããç¥ãããã ããã