- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- ソース を表示
- Go へ行く。
- 1 (2018-12-05 (水) 08:28:26)
- 2 (2018-12-05 (水) 08:29:26)
- 3 (2018-12-10 (月) 00:57:44)
- 4 (2018-12-10 (月) 02:05:02)
- 5 (2018-12-31 (月) 22:39:01)
- 6 (2020-01-31 (金) 21:32:23)
- 7 (2020-02-24 (月) 12:30:25)
- 8 (2020-04-29 (水) 20:10:08)
- 9 (2020-04-30 (木) 01:53:54)
- 10 (2020-05-03 (日) 00:36:29)
- 11 (2020-05-03 (日) 07:02:59)
- 12 (2020-05-03 (日) 20:47:18)
Goの特徴 †
- Googleによって開発され2009年に発表されたプログラミング言語
- ネイティブコードにコンパイルされる
- マルチプラットフォームで動作する
- OSに依存しない、各OSの標準ライブラリに依存しない実行ファイルを生成する
- ガベージコレクションあり
- goroutineという並行処理の仕組みがあり、シンプルかつ効率的な処理が可能
- オブジェクト指向言語ではない
Go言語の基本 †
mainパッケージのmain関数がエントリーポイント
package main import "fmt" func main() { fmt.Printf("Hello, World\n") }
iota †
- ConstSpecのインデックス。
- const宣言ごとに0の値から始まる。
- constのブロック指定でない場合は、0になる。
package main import ( "fmt" "time" ) func main() { termCh := make(chan struct{}) finCh := make(chan struct{}) go func(termCh, finCh chan struct{}) { defer func() { fmt.Println("go: close(finCh)") close(finCh) }() i := 0 for { fmt.Printf("go: running go routine = %d\n", i) i = i + 1 time.Sleep(1 * time.Second) select { case <-termCh: fmt.Println("go: received stop signal from main") return default: } } }(termCh, finCh) times := 0 for { time.Sleep(800 * time.Millisecond) if times > 3 { fmt.Println("main: send stop signal") close(termCh) break } times = times + 1 } <-finCh fmt.Println("main: done") }
参考 https://golang.org/ref/spec#ConstSpec
参考リンク †
- https://golang.org
- https://github.com/golang/go
- https://golang.org/doc/articles/wiki/
- https://go言語.com/doc/- on https://go言語.com/doc/
実装例など †
goroutineのパターンが分かりやすくまとめられている。
数多くの実装例が掲載されている。
初学者に分かりやすく役立つ情報 †
- A Tour of Go - on https://go-tour-jp.appspot.com/list
- Welcome to a tour of Go -on https://go-tour-jp.appspot.com/list
- Goならわかるシステムプログラミング - on http://ascii.jp/elem/000/001/235/1235262/
- Go入門 - on https://www.slideshare.net/takuyaueda967/2016-go
- Go言語の初心者が見ると幸せになれる場所 #golang - on https://qiita.com/tenntenn/items/0e33a4959250d1a55045