golang

goenvの導入

Ubuntu18.04で構築。rbenvとだいたい同じ流れ。 # install goenv git clone https://github.com/syndbg/goenv.git ~/.goenv # bashrcに記載 export GOENV_ROOT=$HOME/.goenv export PATH=$GOENV_ROOT/bin:$PATH eval "$(goenv init -)" # logout # show inst…

【golang】並行プログラミング

並行プログラミングの基本 複数の処理を効率よく行うために、Goは言語自体が並行処理に必要な機能をサポートしている。 ゴルーチン Goにはゴルーチン(Goroutine)という軽量スレッドの仕組みがある。main()関数も1つのゴルーチンの中で実行されている。go構文…

【golang】言語仕様まとめ

インポート import( "fmt" ) func main(){ fmt.Println("hello world") } インポートしたパッケージ内には、パッケージ名.Hoge()でアクセス。 オプションの指定 import( f "fmt" _ "github.com/hoge/fuga" . "strings" ) func main(){ // fmt.Println() => f…

Ubuntu18にgolang【fish】

https://golang.org/dl/からLinux用のURLをコピー # ダウンロード wget https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz # 展開して配置 sudo tar -C /usr/local -xzf go1.14.2.linux-amd64.tar.gz # config.fishにパスを通す set -x GOPATH /usr/loc…