差分

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

この比較画面へのリンク

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
golang [2025/03/05 10:07] – [インストール] ともやんgolang [2025/03/10 07:52] (現在) ともやん
行 1: 行 1:
 ====== Go言語 ====== ====== Go言語 ======
-本家: [[https://golang.org/|The Go Programming Language]]\\ +<WRAP logo>
-ソースコード: [[https://github.com/golang/go|golang/go: The Go programming language]]\\ +
- +
-<WRAP>+
 <WRAP v-align_mid zoomimg w180 x1_2> <WRAP v-align_mid zoomimg w180 x1_2>
 {{ :golang:go-gopher-svgrepo-com.svg |Go Gopher SVG Vector}}\\ {{ :golang:go-gopher-svgrepo-com.svg |Go Gopher SVG Vector}}\\
行 11: 行 8:
 </WRAP> </WRAP>
 <WRAP v-align_mid youtube><html> <WRAP v-align_mid youtube><html>
-  <iframe width="480" height="270" src="https://www.youtube.com/embed/n8F55puGHIs?mute=1&autoplay=1&modestbranding=1&controls=0&rel=0&loop=1"+  <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"           title="YouTube video player" frameborder="0"
           allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"           allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
行 17: 行 14:
 </html></WRAP> </html></WRAP>
 </WRAP> </WRAP>
 +本家: [[https://golang.org/|The Go Programming Language]]\\
 +ソースコード: [[https://github.com/golang/go|golang/go: The Go programming language]]\\
 +
 Go はプログラミング言語の 1 つである。(コンパイラー言語) 2009 年、Google で Robert Griesemer、ロブ・パイク、ケン・トンプソンによって設計された。Go は、静的型付け、C言語の伝統に則ったコンパイル言語、メモリ安全性、ガベージコレクション、構造的型付け、CSP スタイルの並行性などの特徴を持つ。Go のコンパイラ、ツール、およびソースコードは、すべてフリーかつオープンソースである。\\ Go はプログラミング言語の 1 つである。(コンパイラー言語) 2009 年、Google で Robert Griesemer、ロブ・パイク、ケン・トンプソンによって設計された。Go は、静的型付け、C言語の伝統に則ったコンパイル言語、メモリ安全性、ガベージコレクション、構造的型付け、CSP スタイルの並行性などの特徴を持つ。Go のコンパイラ、ツール、およびソースコードは、すべてフリーかつオープンソースである。\\
 \\ \\
行 76: 行 76:
 <WRAP color_term> <WRAP color_term>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
-<b class=GRN>$</b> <b class=HIY>go</b> env GOPATH+<font color="#0087FF"><b>$</b></font> <font color="#26A269">go</font> env GOPATH
 </pre></html></WRAP> </pre></html></WRAP>
 <WRAP color_result><html><pre> <WRAP color_result><html><pre>
行 86: 行 86:
 <WRAP color_term> <WRAP color_term>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
-<b class=GRN>$</b> <b class=HIY>mkdir</b> -p ~/go +<font color="#0087FF"><b>$</b></font> <font color="#26A269">mkdir</font> <font color="#A347BA">-p</font> ~/go 
-<b class=GRN>$</b> <b class=HIY>echo</b> 'export GOPATH=$(go env GOPATH)' >> $HOME/.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> 
-<b class=GRN>$</b> <b class=HIY>echo</b'export PATH=$PATH:$(go env GOPATH)/bin' >> $HOME/.bashrc +<font color="#666666"><b># go initialize</b></font> 
-<b class=GRN>$</b> <b class=HIY>source</b> ~/.bashrc +<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> 
-<b class=GRN>$</b> <b class=HIY>echo</b> $PATH+<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> </pre></html></WRAP>
 <WRAP color_result><html><pre> <WRAP color_result><html><pre>
行 106: 行 109:
 <WRAP color_term> <WRAP color_term>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
-<b class=GRN>$</b> <b class=HIY>mkdir</b> -p ~/go +<font color="#0087FF"><b>$</b></font> <font color="#26A269">mkdir</font> <font color="#A347BA">-p</font> ~/.go 
-<b class=GRN>$</b> <b class=HIY>echo</b> 'export GOPATH=$HOME/go>> $HOME/.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> 
-<b class=GRN>$</b> <b class=HIY>source</b> ~/.bashrc +<font color="#666666"><b># go initialize</b></font> 
-<b class=GRN>$</b> <b class=HIY>go</b> env GOPATH+<font color="#33C7DE"><b>export</b></font> GOPATH=$HOME/.go        
 +<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> </pre></html></WRAP>
 <WRAP color_result><html><pre> <WRAP color_result><html><pre>
-/home/tomoyan/go+/home/tomoyan/.go
 </pre></html></WRAP> </pre></html></WRAP>
 </WRAP> </WRAP>
行 123: 行 131:
 <WRAP color_term> <WRAP color_term>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
-<b class=GRN>$</b> <b class=HIY>mkdir</b> <b class=HIK>-p</b> $(go env GOPATH)/src/haruo && <b class=HIY>cd</b> $(go env GOPATH)/src/haruo +<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 
-<b class=GRN>$</b> <b class=HIY>go</b> mod init example/haruo+<font color="#0087FF"><b>$</b></font> <font color="#26A269">go</font> mod init example/haruo
 </pre></html></WRAP> </pre></html></WRAP>
 <WRAP color_result><html><pre> <WRAP color_result><html><pre>
 go: creating new go.mod: module example/haruo go: creating new go.mod: module example/haruo
-go: to add module requirements and sums: 
- go mod tidy 
- 
 </pre></html></WRAP> </pre></html></WRAP>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
-<b class=GRN>$</b> <b class=HIY>cat</b> go.mod+<font color="#0087FF"><b>$</b></font> <font color="#26A269">cat</font> <u style="text-decoration-style:solid">go.mod</u>
 </pre></html></WRAP> </pre></html></WRAP>
 <WRAP color_result><html><pre> <WRAP color_result><html><pre>
-gmodule example/haruo +module example/haruo
- +
-go 1.20+
  
 +go 1.23.6
 </pre></html></WRAP> </pre></html></WRAP>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
-<b class=GRN>$</b> <b class=HIY>nano</b> haruo.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;</b></font> <u style="text-decoration-style:solid">haruo.go</u
-</pre></html></WRAP> +    <font color="#F66151"><b>package</b></font> main
-<WRAP color_mincode><code go haruo.go> +
-package main+
  
-import "fmt"+    <font color="#26A269">import</font> <font color="#A2734C">&quot;fmt&quot;</font>
  
-func main() { +    <font color="#F66151"><b>func</b></font> main<font color="#2A7BDE"><b>()</b></font> <font color="#2A7BDE"><b>{</b></font> 
-    fmt.Println("Haruo, World!"+        <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> 
-+    <font color="#2A7BDE"><b>}</b></font> 
-</code></WRAP>+<font color="#F66151"><b>EOF</b></font> 
 +</pre></html></WRAP>
 </WRAP> </WRAP>
  
行 158: 行 161:
 <WRAP color_term> <WRAP color_term>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
-<b class=GRN>$</b> <b class=HIY>go</b> run .+<font color="#0087FF"><b>$</b></font> <font color="#26A269">go</font> run <u style="text-decoration-style:solid">.</u>
 </pre></html></WRAP> </pre></html></WRAP>
 <WRAP color_result><html><pre> <WRAP color_result><html><pre>
行 168: 行 171:
 <WRAP color_term> <WRAP color_term>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
-<b class=GRN>$</b> <b class=HIY>go</b> build +<font color="#0087FF"><b>$</b></font> <font color="#26A269">go</font> build 
-<b class=GRN>$</b> <b class=HIY>ls</b>+<font color="#0087FF"><b>$</b></font> <font color="#26A269">ll</font>
 </pre></html></WRAP> </pre></html></WRAP>
 <WRAP color_result><html><pre> <WRAP color_result><html><pre>
-go.mod  <b class=GRN>haruo</b>  haruo.go+合計 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> </pre></html></WRAP>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
-<b class=GRN>$</b> <b class=HIY>./haruo</b>+<font color="#0087FF"><b>$</b></font> <font color="#26A269">./haruo</font>
 </pre></html></WRAP> </pre></html></WRAP>
 <WRAP color_result><html><pre> <WRAP color_result><html><pre>
行 185: 行 191:
 <WRAP color_term> <WRAP color_term>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
-<b class=GRN>$</b> <b class=HIY>go</b> install +<font color="#0087FF"><b>$</b></font> <font color="#26A269">go</font> install 
-<b class=GRN>$</b> <b class=HIY>ls</b> $(go env GOPATH)/bin+<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
 </pre></html></WRAP> </pre></html></WRAP>
 <WRAP color_result><html><pre> <WRAP color_result><html><pre>
-haruo+合計 2084 
 +-rwxr-xr-x 1 tomoyan tomoyan 2130671  3月  5 10:33 <font color="#33D17A"><b>haruo</b></font>
 </pre></html></WRAP> </pre></html></WRAP>
 </WRAP> </WRAP>
行 197: 行 204:
 <WRAP color_term> <WRAP color_term>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
-<b class=GRN>$</b> <b class=HIY>echo</b'export PATH=$PATH:$(go env GOPATH)/bin>> $HOME/.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> 
-<b class=GRN>$</b> <b class=HIY>source</b> ~/.bashrc +<font color="#0087FF"><b>$</b></font> <font color="#26A269">.</font> <u style="text-decoration-style:solid">~/.bashrc</u> 
-<b class=GRN>$</b> <b class=HIY>haruo</b>+<font color="#0087FF"><b>$</b></font> <font color="#26A269">haruo</font>
 </pre></html></WRAP> </pre></html></WRAP>
 <WRAP color_result><html><pre> <WRAP color_result><html><pre>
行 223: 行 230:
   });   });
 </script></html> </script></html>
-[[git>cjbassi/gotop|cjbassi/gotop: A terminal based graphical activity monitor inspired by gtop and vtop]]\\+<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]]\\
 \\ \\
-Go 1.17 から <html><code>go get</code></html>インストールが非推奨になった🤔\\+<html><code>go install</code></html> でインストールする。\\
 <WRAP color_term> <WRAP color_term>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
-<b class=GRN>$</b> <b class=HIY>go</bget github.com/cjbassi/gotop+<font color="#0087FF"><b>$</b></font> <font color="#26A269">go</fontinstall github.com/xxxserxxx/gotop/v4/cmd/gotop@latest
 </pre></html></WRAP> </pre></html></WRAP>
-<WRAP color_result><html><pre> +<WRAP color_result_hlong><html><pre> 
-go: go.mod file not found in current directory or any parent directory+go: downloading github.com/xxxserxxx/gotop/v4 v4.2.0 
- 'go get' is no longer supported outside a module+go: downloading github.com/VictoriaMetrics/metrics v1.18.1 
- To build and install a command, use 'go install' with a version, +go: downloading github.com/gizak/termui/v3 v3.1.0 
- like 'go install example.com/cmd@latest' +go: downloading github.com/droundy/goopt v0.0.0-20220217183150-48d6390ad4d1 
- For more information, see https://golang.org/doc/go-get-install-deprecation +go: downloading github.com/cloudfoundry-attic/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 
- or run 'go help get' or 'go help install'.+godownloading 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> </pre></html></WRAP>
 </WRAP> </WRAP>
  
-<html><code>go install</code></html> でインストする\\+gotop を NVIDIA サポトを有効化して実行するには、''--nvidia'' オプションを付ける😍\\
 <WRAP color_term> <WRAP color_term>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
-<b class=GRN>$</b> <b class=HIY>go</b> install github.com/cjbassi/gotop@latest+<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> </pre></html></WRAP>
 <WRAP color_result><html><pre> <WRAP color_result><html><pre>
-godownloading github.com/cjbassi/gotop v0.0.0-20200829004927-65d76af83079 +Usage of gotop: 
-godownloading github.com/docopt/docopt.go v0.0.0-20180111231733-ee0de3bc6815 + A terminal based graphical activity monitor, inspired by gtop and vtop 
-go: downloading github.com/gizak/termui/v3 v3.0.0 +Options: 
-go: downloading github.com/distatus/battery v0.9.0 +  --remote-name=        Remote: name of remote gotop 
-go: downloading github.com/shirou/gopsutil v2.18.11+incompatible +  --remote-url=         Remote: URL of remote gotop 
-go: downloading github.com/cjbassi/drawille-go v0.0.0-20190126131713-27dc511fe6fd +  --remote-refresh=     RemoteFrequency to refresh data, in seconds 
-go: downloading github.com/mattn/go-runewidth v0.0.4 +  -c, --color=default   Set a colorscheme. 
-go: downloading github.com/mitchellh/go-wordwrap v1.0.0 +  -S, --graphscale=7    Graph scale factor, &gt;0 
-go: downloading github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d +  -v, -V, --version     Print version and exit. 
-godownloading golang.org/x/sys v0.0.0-20190116161447-11f53e031339+  -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 frequencyMost 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 UIUse &quot;-&quot; to pipe. 
 +  -i, --interface=all   Select network interfaceSeveral 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; 
 +      devicesPrints 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> </pre></html></WRAP>
 </WRAP> </WRAP>
  
-gotop を実行する。\\+ 
 +Go 1.17 から <html><code>go get</code></html> でのインストールが非推奨になった🤔\\
 <WRAP color_term> <WRAP color_term>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
-<b class=GRN>$</b> <b class=HIY>gotop</b>+<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> </pre></html></WRAP>
 </WRAP> </WRAP>
  • golang.1741136826.txt.gz
  • 最終更新: 2025/03/05 10:07
  • by ともやん