golang

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
golang [2023/07/17 07:48] – [プログラムの作成] ともやんgolang [2023/07/17 09:18] (現在) – [Go のワークスペース (GOPATH 環境変数)] ともやん
行 141: 行 141:
 </WRAP> </WRAP>
  
-変更するには以下のように設定する。\\+Go でインストールしたコマンドを使用するには <html><code>$(go env GOPATH)/bin</code></html> を PATH に追加する。\\ 
 +<WRAP color_term> 
 +<WRAP color_command><html><pre> 
 +<b class=GRN>$</b> <b class=HIY>mkdir</b> -p ~/go 
 +<b class=GRN>$</b> <b class=HIY>echo</b> 'export GOPATH=$(go env GOPATH)' >> $HOME/.bashrc 
 +<b class=GRN>$</b> <b class=HIY>echo</b> 'export PATH=$PATH:$(go env GOPATH)/bin' >> $HOME/.bashrc 
 +<b class=GRN>$</b> <b class=HIY>source</b> ~/.bashrc 
 +<b class=GRN>$</b> <b class=HIY>echo</b> $PATH 
 +</pre></html></WRAP> 
 +<WRAP color_result><html><pre> 
 +/home/tomoyan/go/bin: ... 
 +</pre></html></WRAP> 
 +<WRAP color_command><html><pre> 
 +<b class=GRN>$</b> <b class=HIY>echo</b> $GOPATH 
 +</pre></html></WRAP> 
 +<WRAP color_result><html><pre> 
 +/home/tomoyan/go 
 +</pre></html></WRAP> 
 +</WRAP> 
 + 
 +GOPATH を変更するには以下のように設定する。\\
 <WRAP color_term> <WRAP color_term>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
行 157: 行 177:
 公式: [[https://go.dev/doc/tutorial/getting-started|Tutorial: Get started with Go - The Go Programming Language]] [[gtr>https://go.dev/doc/tutorial/getting-started|翻訳]]\\ 公式: [[https://go.dev/doc/tutorial/getting-started|Tutorial: Get started with Go - The Go Programming Language]] [[gtr>https://go.dev/doc/tutorial/getting-started|翻訳]]\\
 \\ \\
-Go でプログラムを作成するには、$GOPATH/src サブディレクトリに .go 拡張子を持つファイルを作成する。\\+Go でプログラムを作成するには、<html><code>$(go env GOPATH)/src</code></html> サブディレクトリに .go 拡張子を持つファイルを作成する。\\
 go.mod ファイルを作成してコードの依存関係追跡を有効にする。\\ go.mod ファイルを作成してコードの依存関係追跡を有効にする。\\
 <WRAP color_term> <WRAP color_term>
行 245: 行 265:
  
 ===== Go パッケージのインストール ===== ===== Go パッケージのインストール =====
 +Go パッケージは **go install** コマンドでインストールできる。\\
  
-==== アップストリームの Go パッケージ ==== +==== gotop ==== 
-アップストリームプロジェクトは **go get** コマンドでインストールできる。\\ +<WRAP #gotop_video> 
-<code+{{:golang:gotop_001.mp4?550x330|gotop}}\\ 
-$ go get github.com/gorilla/context +</WRAP> 
-</code+<html><script> 
-ゴ、ゴリラ? (gorilla)...\\+  const video = document.getElementById('gotop_video').getElementsByTagName('video')[0]; 
 +  video.setAttribute('autoPlay','true'); 
 +  video.setAttribute('loop','true'); 
 +  video.addEventListener("canplay", function() { 
 +    setTimeout(function() { 
 +      video.play(); 
 +    }, 1); 
 +  }); 
 +</script></html> 
 +[[git>cjbassi/gotop|cjbassi/gotop: A terminal based graphical activity monitor inspired by gtop and vtop]]\\ 
 +\\ 
 +Go 1.17 から <html><code>go get</code></html> インストールが非推奨になった🤔\\ 
 +<WRAP color_term
 +<WRAP color_command><html><pre> 
 +<b class=GRN>$</b> <b class=HIY>go</b> get github.com/cjbassi/gotop 
 +</pre></html></WRAP
 +<WRAP color_result><html><pre> 
 +go: go.mod file not found in current directory or any parent directory. 
 + 'go get' is no longer supported outside a module. 
 + To build and install a command, use 'go install' with a version, 
 + like 'go install example.com/cmd@latest' 
 + For more information, see https://golang.org/doc/go-get-install-deprecation 
 + or run 'go help get' or 'go help install'.
  
 +</pre></html></WRAP>
 +</WRAP>
  
 +<html><code>go install</code></html> でインストールする。\\
 +<WRAP color_term>
 +<WRAP color_command><html><pre>
 +<b class=GRN>$</b> <b class=HIY>go</b> install github.com/cjbassi/gotop@latest
 +</pre></html></WRAP>
 +<WRAP color_result><html><pre>
 +go: downloading github.com/cjbassi/gotop v0.0.0-20200829004927-65d76af83079
 +go: downloading github.com/docopt/docopt.go v0.0.0-20180111231733-ee0de3bc6815
 +go: downloading github.com/gizak/termui/v3 v3.0.0
 +go: downloading github.com/distatus/battery v0.9.0
 +go: downloading github.com/shirou/gopsutil v2.18.11+incompatible
 +go: downloading github.com/cjbassi/drawille-go v0.0.0-20190126131713-27dc511fe6fd
 +go: downloading github.com/mattn/go-runewidth v0.0.4
 +go: downloading github.com/mitchellh/go-wordwrap v1.0.0
 +go: downloading github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d
 +go: downloading golang.org/x/sys v0.0.0-20190116161447-11f53e031339
 +
 +</pre></html></WRAP>
 +</WRAP>
 +
 +gotop を実行する。\\
 +<WRAP color_term>
 +<WRAP color_command><html><pre>
 +<b class=GRN>$</b> <b class=HIY>gotop</b>
 +</pre></html></WRAP>
 +</WRAP>
  
 ===== 参考文献 ===== ===== 参考文献 =====
  • golang.1689547685.txt.gz
  • 最終更新: 2023/07/17 07:48
  • by ともやん