golang

差分

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

この比較画面へのリンク

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
golang [2023/07/17 05:25] – [インストール] ともやんgolang [2025/05/02 10:38] (現在) – [Go言語] ともやん
行 1: 行 1:
-<html+====== Go言語 ====== 
-  <style+<WRAP logo
-    #go-logo img { +<WRAP v-align_mid zoomimg w180 x1_2
-      displayblock; +{:golang:go-gopher-svgrepo-com.svg |Go Gopher SVG Vector}}\\ 
-      height10rem; +<WRAP desc fsizemin> 
-      max-height: 200px; +[[https://www.svgrepo.com/svg/373635/go-gopher|Go Gopher Vector SVG Icon - SVG Repo]] より\\ 
-      width: 250px; +</WRAP> 
-      margin: 0 auto; +</WRAP> 
-      object-fit: cover; +<WRAP v-align_mid youtube><html> 
-      object-position: 0 0; +  <iframe width="480" height="270" src="https://www.youtube.com/embed/n8F55puGHIs?mute=1&autoplay=1&modestbranding=1&controls=1&rel=0&loop=1" 
-    +          title="YouTube video player" frameborder="0" 
-    #desc { +          allow="accelerometerautoplay; clipboard-writeencrypted-mediagyroscopepicture-in-picture; web-share" 
-      min-width200px; +          referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe
-      overflow:hidden; +</html></WRAP
-    } +</WRAP>
-    #clearfix:after { +
-      content: ""+
-      display: block; +
-      height: 0; +
-      visibility: hidden; +
-      clear: both; +
-    } +
-    #clearfix { +
-      display: inline-table; +
-    } +
-    /* Hides from IE-mac \*/ +
-    * html #clearfix { +
-      height: 1%; +
-    } +
-    #clearfix { +
-      display: block+
-    } +
-  </style+
-</html> +
-====== Go 関連 ======+
 本家: [[https://golang.org/|The Go Programming Language]]\\ 本家: [[https://golang.org/|The Go Programming Language]]\\
 ソースコード: [[https://github.com/golang/go|golang/go: The Go programming language]]\\ ソースコード: [[https://github.com/golang/go|golang/go: The Go programming language]]\\
-<WRAP multi-columns #clearfix> +
-<WRAP left column #go-logo> +
-{{:golang:golang_logo.png|Go Logo}}\\ +
-</WRAP>+
 Go はプログラミング言語の 1 つである。(コンパイラー言語) 2009 年、Google で Robert Griesemer、ロブ・パイク、ケン・トンプソンによって設計された。Go は、静的型付け、C言語の伝統に則ったコンパイル言語、メモリ安全性、ガベージコレクション、構造的型付け、CSP スタイルの並行性などの特徴を持つ。Go のコンパイラ、ツール、およびソースコードは、すべてフリーかつオープンソースである。\\ Go はプログラミング言語の 1 つである。(コンパイラー言語) 2009 年、Google で Robert Griesemer、ロブ・パイク、ケン・トンプソンによって設計された。Go は、静的型付け、C言語の伝統に則ったコンパイル言語、メモリ安全性、ガベージコレクション、構造的型付け、CSP スタイルの並行性などの特徴を持つ。Go のコンパイラ、ツール、およびソースコードは、すべてフリーかつオープンソースである。\\
 \\ \\
 また、軽量スレッディングのための機能、Python のような動的型付け言語のようなプログラミングの容易性、などの特徴もある。Go 処理系としてはコンパイラのみが開発されている。マスコット・キャラクターは Gopher (ホリネズミ)。\\ また、軽量スレッディングのための機能、Python のような動的型付け言語のようなプログラミングの容易性、などの特徴もある。Go 処理系としてはコンパイラのみが開発されている。マスコット・キャラクターは Gopher (ホリネズミ)。\\
-[[https://ja.wikipedia.org/wiki/Go_(%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0%E8%A8%80%E8%AA%9E)|Go (プログラミング言語) - Wikipedia]] より\\ +[[wwjp>Go (プログラミング言語)|Go (プログラミング言語) - Wikiwand]] より\\
-</WRAP>+
  
 ===== インストール ===== ===== インストール =====
 +公式: [[https://go.dev/doc/install|Download and install - The Go Programming Language]] [[gtr>https://go.dev/doc/install|翻訳]]\\
 <WRAP color_term> <WRAP color_term>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
-<b class=GRN>$</b> <b class=HIY>sudo</b> dnf install golang+<font color="#0087FF"><b>$</b></font> <font color="#26A269"><u style="text-decoration-style:solid">sudo</u></font> <font color="#26A269">dnf</font> install <font color="#A347BA">-y</font> golang
 </pre></html></WRAP> </pre></html></WRAP>
 <WRAP color_result_long><html><pre> <WRAP color_result_long><html><pre>
-Fedora 38 - x86_64 - Updates                                                  6.7 kB/s | 6.1 kB     00:00     +リポジトリの更新を読み込み中
-Fedora 38 - x86_64 - Updates                                                  467 kB/s | 2.3 MB     00:05     +リポジトリを読み込みました。 
-Fedora Modular 38 - x86_64 - Updates                                           11 kB/s | 5.2 kB     00:00     +<b>Package                             </b> <b>Arch      </b> <b>Version                              </b> <b>Repository    </b> <b>         Size</b> 
-依存関係が解決しました。 +Installing: 
-============================================================================================================== +<font color="#26A269"> golang                             </fontx86_64     1.23.6-1.fc41                         updates              8.9 MiB 
- パッケージ                    アーキテクチャー     バージョン                    リポジトリー          サイズ +Installing dependencies: 
-============================================================================================================== +<font color="#26A269"go-filesystem                      </font> x86_64     3.6.0-5.fc41                          updates              0.0   B 
-インストール: +<font color="#26A269"golang-bin                         </font> x86_64     1.23.6-1.fc41                         updates            113.9 MiB 
- <class=GRN>golang                       </b> x86_64               1.20.5-1.fc38                 updates               604 k +<font color="#26A269"golang-src                         </fontnoarch     1.23.6-1.fc41                         updates             76.3 MiB 
-依存関係のインストール: +Installing weak dependencies
- <b class=GRN>golang-bin                   </b> x86_64               1.20.5-1.fc38                 updates                58 M +<font color="#26A269"mercurial                          </font> x86_64     6.8.2-1.fc41                          updates             30.8 MiB
- <b class=GRN>golang-src                   </bnoarch               1.20.5-1.fc38                 updates                11 M +
- <b class=GRN>libserf                      </b> x86_64               1.3.9-27.fc38                 fedora                 57 k +
- <b class=GRN>subversion-libs              </b> x86_64               1.14.2-13.fc38                fedora                1.5 M +
- <b class=GRN>utf8proc                     </bx86_64               2.7.0-4.fc38                  fedora                 80 k +
-弱い依存関係のインストール+
- <b class=GRN>subversion                   </b> x86_64               1.14.2-13.fc38                fedora                1.0 M+
  
-トランザクションの概要 +Transaction Summary: 
-============================================================================================================== + Installing:         5 packages
-インストール  7 パッケージ+
  
-ダウンロードサイズの合計: 72 M +パッケージサイズ 47 MiB 、ダウンロードサイズ 47 MiB 。 
-インストール後のサイズ: 214 M +完了、230 MiB のサイズが利用さ(イストル 230 MiB、削除 0 B)。 
-でよろしいでか? [y/N]: y +[1/5] golang-0:1.23.6-1.fc41.x86_64                                       100% | 336.0 KiB/s | 668.9 KiB |  00m02s 
-パッケージのダウド: +[2/5] go-filesystem-0:3.6.0-5.fc41.x86_64                                 100% |  38.6 KiB/s |   9.0 KiB |  00m00s 
-(1/7): libserf-1.3.9-27.fc38.x86_64.rpm                                       141 kB/s |  57 kB     00:00     +[3/5] golang-src-0:1.23.6-1.fc41.noarch                                   100% 762.2 KiB/s |  12.8 MiB |  00m17s 
-(2/7): utf8proc-2.7.0-4.fc38.x86_64.rpm                                       240 kB/s |  80 kB     00:00     +[4/5] mercurial-0:6.8.2-1.fc41.x86_64                                     100% | 390.4 KiB/s |   6.5 MiB |  00m17s 
-(3/7): subversion-1.14.2-13.fc38.x86_64.rpm                                   529 kB/s 1.0 MB     00:01     +[5/5] golang-bin-0:1.23.6-1.fc41.x86_64                                   100% | 915.6 KiB/s |  27.5 MiB |  00m31s 
-(4/7): subversion-libs-1.14.2-13.fc38.x86_64.rpm                              543 kB/s | 1.5 MB     00:02     +------------------------------------------------------------------------------------------------------------------ 
-(5/7)golang-1.20.5-1.fc38.x86_64.rpm                                        212 kB/s | 604 kB     00:02     +[5/5] Total                                                               100% |   1.5 MiB/s |  47.4 MiB |  00m32s
-(6/7): golang-src-1.20.5-1.fc38.noarch.rpm                                    2.0 MB/s |  11 MB     00:05     +
-(7/7): golang-bin-1.20.5-1.fc38.x86_64.rpm                                    2.5 MB/s |  58 MB     00:23     +
--------------------------------------------------------------------------------------------------------------- +
-合計                                                                          2.7 MB/s |  72 MB     00:26      +
-トランザクションの確認を実行中 +
-トランザクションの確認に成功しました。 +
-トランザクションのテストを実行中 +
-トランザクションのテストに成功しました。+
 トランザクションを実行中 トランザクションを実行中
-  scriptletの実行中: golang-1.20.5-1.fc38.x86_64                                                          1/1  +[1/7] パッケージ ファイルを検証                               100% |   7.0   B/s |   5.0   B |  00m01s 
-  準備             :                                                                                      1/1  +[2/7] トランザクショの準備                                   100% |   0.0   B/s |   5.0   B |  00m08s 
-  ンストー中   : golang-src-1.20.5-1.fc38.noarch                                                      1/7  +[3/7インストール中 go-filesystem-0:3.6.0-5.fc41.x86_64           100% | 876.0   B/s | 392.0   B |  00m00s 
-  イストール中   : utf8proc-2.7.0-4.fc38.x86_64                                                         2/7  +[4/7インストール中 golang-src-0:1.23.6-1.fc41.noarch             100% |  21.8 MiB/s |  77.2 MiB |  00m04s 
-  インストール中   : libserf-1.3.9-27.fc38.x86_64                                                         3/7  +[5/7インストール中 golang-bin-0:1.23.6-1.fc41.x86_64             100% |  64.9 MiB/s | 113.9 MiB |  00m02s 
-  インストール中   : subversion-libs-1.14.2-13.fc38.x86_64                                                4/7  +[6/7インストール中 golang-0:1.23.6-1.fc41.x86_64                 100% |  25.2 MiB/s |   8.9 MiB |  00m00s 
-  インストール中   subversion-1.14.2-13.fc38.x86_64                                                     5/7  +[7/7] インストール中 mercurial-0:6.8.2-1.fc41.x86_64               100% |   1.4 MiB/s |  31.1 MiB |  00m22s 
-  scriptletの実行中: subversion-1.14.2-13.fc38.x86_64                                                     5/7  +完了しました! 
-  インストール中   : golang-1.20.5-1.fc38.x86_64                                                          6/7  +</pre></html></WRAP> 
-  インストール中   : golang-bin-1.20.5-1.fc38.x86_64                                                      7/7  +<WRAP color_command><html><pre> 
-  scriptletの実行中: golang-bin-1.20.5-1.fc38.x86_64                                                      7/7  +<font color="#0087FF"><b>$</b></font> <font color="#26A269">go</font> version 
-  検証             : libserf-1.3.9-27.fc38.x86_64                                                         1/7  +</pre></html></WRAP> 
-  検証             subversion-1.14.2-13.fc38.x86_64                                                     2/7  +<WRAP color_result><html><pre> 
-  検証             : subversion-libs-1.14.2-13.fc38.x86_64                                                3/7  +go version go1.23.6 linux/amd64 
-  検証             : utf8proc-2.7.0-4.fc38.x86_64                                                         4/7  +</pre></html></WRAP> 
-  検証             : golang-1.20.5-1.fc38.x86_64                                                          5/ +</WRAP>
-  検証             : golang-bin-1.20.5-1.fc38.x86_64                                                      6/ +
-  検証             : golang-src-1.20.5-1.fc38.noarch                                                      7/+
  
-インル済み: +==== Go のワークス (GOPATH 環境変数) ==== 
-  golang-1.20.5-1.fc38.x86_64     golang-bin-1.20.5-1.fc38.x86_64     golang-src-1.20.5-1.fc38.noarch          +公式[[https://go.dev/doc/gopath_code|How to Write Go Code (with GOPATH) The Go Programming Language]] [[gtr>https://go.dev/doc/gopath_code|翻訳]]\\ 
-  libserf-1.3.9-27.fc38.x86_64    subversion-1.14.2-13.fc38.x86_64    subversion-libs-1.14.2-13.fc38.x86_64    +Go のワークスペースは標準で <html><code>$HOME/go</code></html> です。\\ 
-  utf8proc-2.7.0-4.fc38.x86_64    +<WRAP color_term> 
- +<WRAP color_command><html><pre> 
-完了しました!+<font color="#0087FF"><b>$</b></font> <font color="#26A269">go</font> env GOPATH 
 +</pre></html></WRAP> 
 +<WRAP color_result><html><pre> 
 +/home/tomoyan/go 
 +</pre></html></WRAP> 
 +</WRAP>
  
 +Go でインストールしたコマンドを使用するには <html><code>$(go env GOPATH)/bin</code></html> を PATH に追加する。\\
 +<WRAP color_term>
 +<WRAP color_command><html><pre>
 +<font color="#0087FF"><b>$</b></font> <font color="#26A269">mkdir</font> <font color="#A347BA">-p</font> ~/go
 +<font color="#0087FF"><b>$</b></font> <font color="#26A269">cat</font> <font color="#2A7BDE"><b>&lt;&lt;</b></font> <font color="#A2734C">&apos;EOF&apos;</font> <font color="#2A7BDE"><b>&gt;&gt;</b></font> <u style="text-decoration-style:solid">~/.commonshrc</u>
 +<font color="#666666"><b># go initialize</b></font>
 +<font color="#33C7DE"><b>export</b></font> GOPATH=<font color="#A347BA">$</font><font color="#2A7BDE"><b>(</b></font><font color="#26A269">go</font> env GOPATH<font color="#2A7BDE"><b>)</b></font>
 +<font color="#33C7DE"><b>export</b></font> PATH=$PATH:<font color="#A347BA">$</font><font color="#2A7BDE"><b>(</b></font><font color="#26A269">go</font> env GOPATH<font color="#2A7BDE"><b>)</b></font>/bin
 +<font color="#F66151"><b>EOF</b></font>
 +<font color="#0087FF"><b>$</b></font> <font color="#26A269">.</font> <u style="text-decoration-style:solid">~/.bashrc</u>
 +<font color="#0087FF"><b>$</b></font> <font color="#26A269">echo</font><font color="#999999"> $GOPATH</font>
 +</pre></html></WRAP>
 +<WRAP color_result><html><pre>
 +/home/tomoyan/go/bin: ...
 </pre></html></WRAP> </pre></html></WRAP>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
-<b class=GRN>$</b> <b class=HIY>go</b> version+<b class=GRN>$</b> <b class=HIY>echo</b> $GOPATH
 </pre></html></WRAP> </pre></html></WRAP>
 <WRAP color_result><html><pre> <WRAP color_result><html><pre>
-go version go1.20.5 linux/amd64+/home/tomoyan/go
 </pre></html></WRAP> </pre></html></WRAP>
 </WRAP> </WRAP>
  
-GOPATH 環境変数を設定する。\\ +GOPATH を変更するには以下のように設定する。\\ 
-<code+<WRAP color_term
-$ mkdir -p ~/go +<WRAP color_command><html><pre> 
-echo 'export GOPATH=$HOME/go>> $HOME/.bashrc +<font color="#0087FF"><b>$</b></font> <font color="#26A269">mkdir</font> <font color="#A347BA">-p</font> ~/.go 
-source ~/.bashrc +<font color="#0087FF"><b>$</b></font> <font color="#26A269">cat</font> <font color="#2A7BDE"><b>&lt;&lt;</b></font> <font color="#A2734C">&apos;EOF&apos;</font> <font color="#2A7BDE"><b>&gt;&gt;</b></font> <u style="text-decoration-style:solid">~/.commonshrc</u> 
-$ go env GOPATH +<font color="#666666"><b># go initialize</b></font> 
-/home/tomoyan/go +<font color="#33C7DE"><b>export</b></font> GOPATH=$HOME/.go        
-</code>+<font color="#33C7DE"><b>export</b></font> PATH=$PATH:<font color="#A347BA">$</font><font color="#2A7BDE"><b>(</b></font><font color="#26A269">go</font> env GOPATH<font color="#2A7BDE"><b>)</b></font>/bin 
 +<font color="#F66151"><b>EOF</b></font> 
 +<font color="#0087FF"><b>$</b></font> <font color="#26A269">.</font> <u style="text-decoration-style:solid">~/.bashrc</u> 
 +<font color="#0087FF"><b>$</b></font> <font color="#26A269">echo</font><font color="#999999"> $GOPATH</font> 
 +<font color="#0087FF"><b>$</b></font> <font color="#26A269">go</font><font color="#999999"> env GOPATH</font> 
 +</pre></html></WRAP> 
 +<WRAP color_result><html><pre> 
 +/home/tomoyan/.go 
 +</pre></html></WRAP> 
 +</WRAP>
  
 ===== プログラムの作成 ===== ===== プログラムの作成 =====
-Go でプログラムを作成するには、$GOPATH/src サブディレクトリに .go 拡張子を持つファイルを作成する。\\ +公式: [[https://go.dev/doc/tutorial/getting-started|Tutorial: Get started with Go - The Go Programming Language]] [[gtr>https://go.dev/doc/tutorial/getting-started|翻訳]]\\ 
-<code+\\ 
-$ mkdir -p $GOPATH/src/hello && cd $GOPATH/src/hello +Go でプログラムを作成するには、<html><code>$(go env GOPATH)/src</code></html> サブディレクトリに .go 拡張子を持つファイルを作成する。\\ 
-vi hello.go +go.mod ファイルを作成してコードの依存関係追跡を有効にする。\\ 
-</code+<WRAP color_term
-<code go hello.go> +<WRAP color_command><html><pre> 
-package main+<font color="#0087FF"><b>$</b></font> <font color="#26A269">mkdir</font> <font color="#A347BA">-p</font> <font color="#A347BA">$</font><font color="#2A7BDE"><b>(</b></font><font color="#26A269">go</font> env GOPATH<font color="#2A7BDE"><b>)</b></font>/src/haruo <font color="#2A7BDE"><b>&amp;&amp;</b></font> <font color="#26A269">cd</font> <font color="#A347BA">$</font><font color="#2A7BDE"><b>(</b></font><font color="#26A269">go</font> env GOPATH<font color="#2A7BDE"><b>)</b></font>/src/haruo 
 +<font color="#0087FF"><b>$</b></font> <font color="#26A269">go</font> mod init example/haruo 
 +</pre></html></WRAP
 +<WRAP color_result><html><pre> 
 +go: creating new go.mod: module example/haruo 
 +</pre></html></WRAP> 
 +<WRAP color_command><html><pre> 
 +<font color="#0087FF"><b>$</b></font> <font color="#26A269">cat</font> <u style="text-decoration-style:solid">go.mod</u
 +</pre></html></WRAP> 
 +<WRAP color_result><html><pre> 
 +module example/haruo
  
-import "fmt"+go 1.23.6 
 +</pre></html></WRAP> 
 +<WRAP color_command><html><pre> 
 +<font color="#0087FF"><b>$</b></font> <font color="#26A269">cat</font> <font color="#2A7BDE"><b>&lt;&lt;</b></font> <font color="#A2734C">&apos;EOF&apos;</font> <font color="#2A7BDE"><b>&gt;</b></font> <u style="text-decoration-style:solid">haruo.go</u> 
 +    <font color="#F66151"><b>package</b></font> main
  
-func main() { +    <font color="#26A269">import</font> <font color="#A2734C">&quot;fmt&quot;</font>
-    fmt.Println("Hello, World!"+
-+
-</code>+
  
-変更を保存し、同じディレクトリで hello.go を実行する。\\ +    <font color="#F66151"><b>func</b></font> main<font color="#2A7BDE"><b>()</b></font> <font color="#2A7BDE"><b>{</b></font> 
-<code+        <font color="#F66151"><b>fmt.Println</b></font><font color="#33D17A"><b>(</b></font><font color="#F66151"><b>&quot;Haruo, World!&quot;</b></font><font color="#33D17A"><b>)</b></font> 
-$ go run hello.go +    <font color="#2A7BDE"><b>}</b></font> 
-Hello, World! +<font color="#F66151"><b>EOF</b></font> 
-</code>+</pre></html></WRAP> 
 +</WRAP> 
 + 
 +変更を保存し、同じディレクトリで haruo.go を実行する。\\ 
 +<WRAP color_term
 +<WRAP color_command><html><pre> 
 +<font color="#0087FF"><b>$</b></font> <font color="#26A269">go</font> run <u style="text-decoration-style:solid">.</u> 
 +</pre></html></WRAP> 
 +<WRAP color_result><html><pre> 
 +Haruo, World! 
 +</pre></html></WRAP> 
 +</WRAP>
  
 hello.go をビルドするは簡単である。\\ hello.go をビルドするは簡単である。\\
-<code+<WRAP color_term
-$ go build +<WRAP color_command><html><pre> 
-ls +<font color="#0087FF"><b>$</b></font> <font color="#26A269">go</font> build 
-hello  hello.go +<font color="#0087FF"><b>$</b></font> <font color="#26A269">ll</font> 
-$ ./hello +</pre></html></WRAP> 
-Hello, World! +<WRAP color_result><html><pre> 
-</code>+合計 2092 
 +-rw-r--r-- 1 tomoyan tomoyan      32  3月  5 10:31 go.mod 
 +-rwxr-xr-x 1 tomoyan tomoyan 2130671  3月  5 10:42 <font color="#33D17A"><b>haruo</b></font> 
 +-rw-r--r-- 1 tomoyan tomoyan     107  3月  5 10:32 haruo.go 
 +</pre></html></WRAP> 
 +<WRAP color_command><html><pre> 
 +<font color="#0087FF"><b>$</b></font> <font color="#26A269">./haruo</font> 
 +</pre></html></WRAP> 
 +<WRAP color_result><html><pre> 
 +Haruo, World! 
 +</pre></html></WRAP> 
 +</WRAP>
  
 さらに **go install** で **$GOPATH/bin** にインストールされる。 \\ さらに **go install** で **$GOPATH/bin** にインストールされる。 \\
-<code+<WRAP color_term
-$ go install +<WRAP color_command><html><pre> 
-ls $GOPATH/bin +<font color="#0087FF"><b>$</b></font> <font color="#26A269">go</font> install 
-hello +<font color="#0087FF"><b>$</b></font> <font color="#26A269">ll</font> <font color="#A347BA">$</font><font color="#2A7BDE"><b>(</b></font><font color="#26A269">go</font> env GOPATH<font color="#2A7BDE"><b>)</b></font>/bin 
-</code>+</pre></html></WRAP> 
 +<WRAP color_result><html><pre> 
 +合計 2084 
 +-rwxr-xr-x 1 tomoyan tomoyan 2130671  3月  5 10:33 <font color="#33D17A"><b>haruo</b></font> 
 +</pre></html></WRAP> 
 +</WRAP>
 また、**$GOPATH/pkg** のすべての依存関係を構築およびキャッシュする。\\ また、**$GOPATH/pkg** のすべての依存関係を構築およびキャッシュする。\\
  
 プログラムは **$GOPATH/bin** にインストールされるため、一般的には PATH 環境変数に追加して、フルパスを指定せずに Go プログラムを実行できるようにする。\\ プログラムは **$GOPATH/bin** にインストールされるため、一般的には PATH 環境変数に追加して、フルパスを指定せずに Go プログラムを実行できるようにする。\\
-<code+<WRAP color_term
-$ echo 'export PATH=$PATH:$GOPATH/bin>> $HOME/.bashrc +<WRAP color_command><html><pre> 
-source ~/.bashrc +<font color="#0087FF"><b>$</b></font> <font color="#26A269">echo</font> <font color="#A2734C">&apos;export PATH=$PATH:$</font><font color="#2A7BDE"><b>(</b></font><font color="#A2734C">go env GOPATH</font><font color="#2A7BDE"><b>)</b></font><font color="#A2734C">/bin&apos;</font<font color="#2A7BDE"><b>&gt;&gt;</b></font> <u style="text-decoration-style:solid">~/.bashrc</u> 
-hello +<font color="#0087FF"><b>$</b></font> <font color="#26A269">.</font> <u style="text-decoration-style:solid">~/.bashrc</u> 
-Hello, World! +<font color="#0087FF"><b>$</b></font> <font color="#26A269">haruo</font> 
-</code>+</pre></html></WRAP> 
 +<WRAP color_result><html><pre> 
 +Haruo, World! 
 +</pre></html></WRAP> 
 +</WRAP>
  
 ===== 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> 
 +<del>[[git>cjbassi/gotop|cjbassi/gotop: A terminal based graphical activity monitor inspired by gtop and vtop]]</del>\\ 
 +[[git>xxxserxxx/gotop|GitHub - xxxserxxx/gotop: A terminal based graphical activity monitor inspired by gtop and vtop]]\\ 
 +\\ 
 +<html><code>go install</code></html> でインストールる。\\ 
 +<WRAP color_term
 +<WRAP color_command><html><pre> 
 +<font color="#0087FF"><b>$</b></font> <font color="#26A269">go</font> install github.com/xxxserxxx/gotop/v4/cmd/gotop@latest 
 +</pre></html></WRAP
 +<WRAP color_result_hlong><html><pre> 
 +go: downloading github.com/xxxserxxx/gotop/v4 v4.2.
 +go: downloading github.com/VictoriaMetrics/metrics v1.18.1 
 +go: downloading github.com/gizak/termui/v3 v3.1.0 
 +go: downloading github.com/droundy/goopt v0.0.0-20220217183150-48d6390ad4d1 
 +go: downloading github.com/cloudfoundry-attic/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 
 +go: downloading github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0 
 +go: downloading github.com/xxxserxxx/lingo/v2 v2.0.1 
 +go: downloading github.com/anatol/smart.go v0.0.0-20220917195147-c0b00d90f8cc 
 +go: downloading github.com/jaypipes/ghw v0.9.0 
 +go: downloading github.com/shirou/gopsutil v3.20.12+incompatible 
 +go: downloading github.com/VividCortex/ewma v1.2.0 
 +go: downloading github.com/distatus/battery v0.10.0 
 +go: downloading github.com/mattn/go-runewidth v0.0.13 
 +go: downloading github.com/mitchellh/go-wordwrap v1.0.1 
 +go: downloading github.com/nsf/termbox-go v1.1.1 
 +go: downloading github.com/valyala/histogram v1.2.0 
 +go: downloading github.com/BurntSushi/toml v1.1.0 
 +go: downloading golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41 
 +go: downloading github.com/valyala/fastrand v1.1.0 
 +go: downloading github.com/rivo/uniseg v0.2.0 
 +go: downloading github.com/ghodss/yaml v1.0.0 
 +go: downloading github.com/jaypipes/pcidb v1.0.0 
 +go: downloading gopkg.in/yaml.v2 v2.4.0 
 +go: downloading github.com/mitchellh/go-homedir v1.1.0 
 +</pre></html></WRAP> 
 +</WRAP>
  
 +gotop を実行する😉\\
 +<WRAP color_term>
 +<WRAP color_command><html><pre>
 +<font color="#0087FF"><b>$</b></font> <font color="#26A269">gotop</font>
 +</pre></html></WRAP>
 +</WRAP>
  
 +gotop を NVIDIA サポートを有効化して実行するには、''--nvidia'' オプションを付ける😍\\
 +<WRAP color_term>
 +<WRAP color_command><html><pre>
 +<font color="#0087FF"><b>$</b></font> <font color="#26A269">gotop</font> <font color="#A347BA">--nvidia</font>
 +</pre></html></WRAP>
 +</WRAP>
 +
 +使い方\\
 +<WRAP color_term>
 +<WRAP color_command><html><pre>
 +<font color="#0087FF"><b>$</b></font> <font color="#26A269">gotop</font> <font color="#A347BA">--help</font>
 +</pre></html></WRAP>
 +<WRAP color_result><html><pre>
 +Usage of gotop:
 + A terminal based graphical activity monitor, inspired by gtop and vtop
 +Options:
 +  --remote-name=        Remote: name of remote gotop
 +  --remote-url=         Remote: URL of remote gotop
 +  --remote-refresh=     Remote: Frequency to refresh data, in seconds
 +  -c, --color=default   Set a colorscheme.
 +  -S, --graphscale=7    Graph scale factor, &gt;0
 +  -v, -V, --version     Print version and exit.
 +  -p, --percpu          Show each CPU in the CPU widget.
 +  --no-percpu           Show aggregate CPU in the CPU widget.
 +  -a, --averagecpu      Show average CPU in the CPU widget.
 +  --no-averagecpu       Disable show average CPU in the CPU widget.
 +  --fahrenheit          Show temperatures in fahrenheit.
 +  --celsius             Show temperatures in celsius.
 +  -s, --statusbar       Show a statusbar with the time.
 +  --no-statusbar        Disable statusbar.
 +  -r, --rate=1s         Refresh frequency. Most time units accepted.  &quot;1m&quot; = refresh every minute.  &quot;100ms&quot; = refresh every 100ms.
 +  -l, --layout=default  Name of layout spec file for the UI. Use &quot;-&quot; to pipe.
 +  -i, --interface=all   Select network interface. Several interfaces can be defined using comma separated values. Interfaces can also be ignored using &quot;!&quot;
 +  -x, --export=         Enable metrics for export on the specified port.
 +  --mbps                Show network rate as mbps.
 +  --bytes               args.no-mbps
 +  --test                Runs tests and exits with success/failure code.
 +  --no-test             Disable tests.
 +  -C                    Config file to use instead of default (MUST BE FIRST ARGUMENT).
 +  --nvidia              Enable NVidia GPU metrics.
 +  --no-nvidia           Disable NVidia GPU metrics.
 +  --list=               List &lt;devices|layouts|colorschemes|paths|keys|langs&gt;
 +      devices: Prints out device names for filterable widgets
 +      layouts: Lists built-in layouts
 +      colorschemes: Lists built-in colorschemes
 +      paths: List out configuration file search paths
 +      widgets: Widgets that can be used in a layout
 +      keys: Show the keyboard bindings.
 +      langs: Show supported language translations.
 +  --write-config  Write out a default config file.
 +  -h, --help      Show usage message
 +  --version       Show version
 +
 +</pre></html></WRAP>
 +</WRAP>
 +
 +
 +Go 1.17 から <html><code>go get</code></html> でのインストールが非推奨になった🤔\\
 +<WRAP color_term>
 +<WRAP color_command><html><pre>
 +<font color="#0087FF"><b>$</b></font> <font color="#26A269">go</font> get github.com/xxxserxxx/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>
  
 ===== 参考文献 ===== ===== 参考文献 =====
  • golang.1689539128.txt.gz
  • 最終更新: 2023/07/17 05:25
  • by ともやん