差分
このページの2つのバージョン間の差分を表示します。
次のリビジョン | 前のリビジョン | ||
golang [2019/09/17 12:17] – 作成 ともやん | golang [2023/07/17 09:18] (現在) – [Go のワークスペース (GOPATH 環境変数)] ともやん | ||
---|---|---|---|
行 1: | 行 1: | ||
< | < | ||
< | < | ||
- | # | + | # |
- | display: block; | + | |
height: 10rem; | height: 10rem; | ||
max-height: 200px; | max-height: 200px; | ||
- | width: 250px; | + | width: 250px;*/ |
margin: 0 auto; | margin: 0 auto; | ||
object-fit: cover; | object-fit: cover; | ||
行 13: | 行 13: | ||
min-width: 200px; | min-width: 200px; | ||
overflow: | overflow: | ||
+ | } | ||
+ | # | ||
+ | content: ""; | ||
+ | display: block; | ||
+ | height: 0; | ||
+ | visibility: hidden; | ||
+ | clear: both; | ||
+ | } | ||
+ | #clearfix { | ||
+ | display: inline-table; | ||
+ | } | ||
+ | /* Hides from IE-mac \*/ | ||
+ | * html #clearfix { | ||
+ | height: 1%; | ||
+ | } | ||
+ | #clearfix { | ||
+ | display: block; | ||
} | } | ||
</ | </ | ||
</ | </ | ||
====== Go 関連 ====== | ====== Go 関連 ====== | ||
- | <WRAP multi-columns> | + | 本家: [[https:// |
- | < | + | ソースコード: |
- | {{:golang: | + | <WRAP multi-columns |
- | </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:// | ||
+ | </ | ||
+ | |||
+ | ===== インストール ===== | ||
+ | 公式: [[https:// | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result_long>< | ||
+ | Fedora 38 - x86_64 - Updates | ||
+ | Fedora 38 - x86_64 - Updates | ||
+ | Fedora Modular 38 - x86_64 - Updates | ||
+ | 依存関係が解決しました。 | ||
+ | ============================================================================================================== | ||
+ | | ||
+ | ============================================================================================================== | ||
+ | インストール: | ||
+ | <b class=GRN> | ||
+ | 依存関係のインストール: | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | 弱い依存関係のインストール: | ||
+ | <b class=GRN> | ||
+ | |||
+ | トランザクションの概要 | ||
+ | ============================================================================================================== | ||
+ | インストール | ||
+ | |||
+ | ダウンロードサイズの合計: | ||
+ | インストール後のサイズ: | ||
+ | これでよろしいですか? | ||
+ | パッケージのダウンロード: | ||
+ | (1/7): libserf-1.3.9-27.fc38.x86_64.rpm | ||
+ | (2/7): utf8proc-2.7.0-4.fc38.x86_64.rpm | ||
+ | (3/7): subversion-1.14.2-13.fc38.x86_64.rpm | ||
+ | (4/7): subversion-libs-1.14.2-13.fc38.x86_64.rpm | ||
+ | (5/7): golang-1.20.5-1.fc38.x86_64.rpm | ||
+ | (6/7): golang-src-1.20.5-1.fc38.noarch.rpm | ||
+ | (7/7): golang-bin-1.20.5-1.fc38.x86_64.rpm | ||
+ | -------------------------------------------------------------------------------------------------------------- | ||
+ | 合計 | ||
+ | トランザクションの確認を実行中 | ||
+ | トランザクションの確認に成功しました。 | ||
+ | トランザクションのテストを実行中 | ||
+ | トランザクションのテストに成功しました。 | ||
+ | トランザクションを実行中 | ||
+ | scriptletの実行中: | ||
+ | 準備 | ||
+ | インストール中 | ||
+ | インストール中 | ||
+ | インストール中 | ||
+ | インストール中 | ||
+ | インストール中 | ||
+ | scriptletの実行中: | ||
+ | インストール中 | ||
+ | インストール中 | ||
+ | scriptletの実行中: | ||
+ | 検証 | ||
+ | 検証 | ||
+ | 検証 | ||
+ | 検証 | ||
+ | 検証 | ||
+ | 検証 | ||
+ | 検証 | ||
+ | |||
+ | インストール済み: | ||
+ | golang-1.20.5-1.fc38.x86_64 | ||
+ | libserf-1.3.9-27.fc38.x86_64 | ||
+ | utf8proc-2.7.0-4.fc38.x86_64 | ||
+ | |||
+ | 完了しました! | ||
+ | |||
+ | </ | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | go version go1.20.5 linux/amd64 | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ==== Go のワークスペース (GOPATH 環境変数) ==== | ||
+ | 公式: [[https:// | ||
+ | Go のワークスペースは標準で < | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | / | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | Go でインストールしたコマンドを使用するには < | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | / | ||
+ | </ | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | / | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | GOPATH を変更するには以下のように設定する。\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | / | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== プログラムの作成 ===== | ||
+ | 公式: [[https:// | ||
+ | \\ | ||
+ | Go でプログラムを作成するには、< | ||
+ | go.mod ファイルを作成してコードの依存関係追跡を有効にする。\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | go: creating new go.mod: module example/ | ||
+ | go: to add module requirements and sums: | ||
+ | go mod tidy | ||
+ | |||
+ | </ | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | gmodule example/ | ||
+ | |||
+ | go 1.20 | ||
+ | |||
+ | </ | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_mincode>< | ||
+ | package main | ||
+ | |||
+ | import " | ||
+ | |||
+ | func main() { | ||
+ | fmt.Println(" | ||
+ | } | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | 変更を保存し、同じディレクトリで haruo.go を実行する。\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | Haruo, World! | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | hello.go をビルドするは簡単である。\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | go.mod | ||
+ | </ | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | Haruo, World! | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | さらに **go install** で **$GOPATH/ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | haruo | ||
+ | </ | ||
+ | </ | ||
+ | また、**$GOPATH/ | ||
+ | |||
+ | プログラムは **$GOPATH/ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | Haruo, World! | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== Go パッケージのインストール ===== | ||
+ | Go パッケージは **go install** コマンドでインストールできる。\\ | ||
+ | |||
+ | ==== gotop ==== | ||
+ | <WRAP # | ||
+ | {{: | ||
+ | </ | ||
+ | < | ||
+ | const video = document.getElementById(' | ||
+ | video.setAttribute(' | ||
+ | video.setAttribute(' | ||
+ | video.addEventListener(" | ||
+ | setTimeout(function() { | ||
+ | video.play(); | ||
+ | }, 1); | ||
+ | }); | ||
+ | </ | ||
+ | [[git> | ||
+ | \\ | ||
+ | Go 1.17 から < | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | 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' | ||
+ | like 'go install example.com/ | ||
+ | For more information, | ||
+ | or run 'go help get' or 'go help install' | ||
+ | |||
+ | </ | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
+ | <WRAP color_result>< | ||
+ | go: downloading github.com/ | ||
+ | go: downloading github.com/ | ||
+ | go: downloading github.com/ | ||
+ | go: downloading github.com/ | ||
+ | go: downloading github.com/ | ||
+ | go: downloading github.com/ | ||
+ | go: downloading github.com/ | ||
+ | go: downloading github.com/ | ||
+ | go: downloading github.com/ | ||
+ | go: downloading golang.org/ | ||
+ | |||
+ | </ | ||
</ | </ | ||
+ | |||
+ | gotop を実行する。\\ | ||
+ | <WRAP color_term> | ||
+ | <WRAP color_command>< | ||
+ | <b class=GRN> | ||
+ | </ | ||
</ | </ | ||
+ | |||
+ | ===== 参考文献 ===== | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | |||
+ | [[https:// | ||
+ | **Grumpy**\\ | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | |||
+ | ==== 付録 ==== | ||
+ | [[tw> | ||