本文へスキップ
製品デスクトップツールTASTECAD図面の確認TASTEFILESファイル管理TASTEFTPファイル転送TASTESSHリモートワークスペースTASTEZIP圧縮と展開TASTEWINMファイル管理開発ツールTASTECODERust 統合開発環境TASTESTUDIO統合開発・テスト環境TASTEETLデータ統合(ETL)サーバーTASTEREMOTEリモートデスクトップサーバーTASTEGEO空間情報サーバーTASTEMAILメールワークスペース投資TASTESTOCK株式自動売買デスクトップアプリはじめるダウンロードドキュメント購入すべての製品
マーケットプレイス
ニュース
技術ニュース今日の開発ニュース開発ドキュメントプログラミング言語RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWebフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngularサーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Expressアプリ・デスクトップ フレームワークTauriFlutterReact NativeElectronアルゴリズムアルゴリズムの基礎主要アルゴリズム発展アルゴリズム実務のアルゴリズム
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケースコミュニティガイド
協業技術移転ウェブサイト構築デスクトップアプリ構築リリース・決済パイプライン販売パートナーお問い合わせ
サービスリモートデスクトップインストールパッケージのカスタマイズ
TASTEDEV
製品

デスクトップツール

TASTECAD複雑な図面を、軽やかにひらくTASTEFILES必要なファイルだけを、最速でTASTEFTPファイルが行き交う、いちばん端正な道TASTESSHサーバーとあなたを、より確かにつなぐTASTEZIPより速くまとめ、より安全にひらくTASTEWINM2つの画面で整理する、キーボード中心のファイルマネージャー

開発ツール

TASTECODERust アプリの編集・ビルド・デバッグ・テストまでひとつのウィンドウでTASTESTUDIO編集からリモートテスト、承認した AI 修正までTASTEETL値を見ながら、データを運ぶ

サーバー

TASTEREMOTE自社サーバーで運用するリモートデスクトップTASTEGEOGeoServer 互換の空間情報サーバーを Rust で作り直しますTASTEMAILメールの主導権を、もう一度自分の手に

投資

TASTESTOCKいつ・何を。自分で決めたルールどおりに動く株式自動売買

はじめる

ダウンロード全製品の最新版ドキュメント各製品の使い方購入サブスクリプション・永久ライセンスすべての製品全製品を一覧で
すべての製品
マーケットプレイスニュース
技術

ニュース

今日の開発ニュース言語・フレームワーク・GitHub・AI の公式発表開発ドキュメント言語・フレームワーク・アルゴリズムのガイド

プログラミング言語

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

フレームワーク

Webフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngular
サーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
アプリ・デスクトップ フレームワークTauriFlutterReact NativeElectron

アルゴリズム

アルゴリズムの基礎計算量解析 · ソート · 探索 · 基本データ構造 · 木構造とヒープ主要アルゴリズムグラフ探索 · 最短経路と最小全域木 · 動的計画法 · 貪欲法 · 分割統治法 · バックトラッキング発展アルゴリズム文字列アルゴリズム · 数学と整数論 · ビット演算 · セグメント木 · Union-Find実務のアルゴリズムコーディング面接対策 · LRUキャッシュ · レート制限 · コンシステントハッシュ法
開発ドキュメントをすべて見る
コミュニティ
プロジェクトビルダーと作品を探す開発ログ決定と試行錯誤プロンプト再利用できる指示AIツールの問題Claude・Codex・Gemini の問題と回避策ショーケース完成した成果コミュニティガイドオープンにつくる方法
協業
技術移転Rust・egui でネイティブアプリを作るウェブサイト構築10言語、アカウント、ドキュメントとダウンロードデスクトップアプリ構築Rust・egui、WebView なしリリース・決済パイプライン署名・MSI・deb・rpm・AppImage・ハッシュ販売パートナー紹介して決済額の30%お問い合わせ構築・提携・投資のご相談
サービス
リモートデスクトップブラウザから自分のパソコンへインストールパッケージのカスタマイズ必要な機能だけ、設定は事前に
購入
JA
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
ログイン
ログイン
TASTEDEV

小さなツールから、より良い開発へ。

support@tastedev.netTASTEDEVを支援
製品製品ラインナップ購入ドキュメントダウンロードマーケットプレイスサポート
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケース
ポリシー会社概要プライバシーポリシー利用規約サブスクリプション規約返金ポリシーコミュニティガイドライン
アカウントログイン新規登録
訪問者
今日
昨日
累計閲覧
商号
GXSOFT
代表者
CHOI YOUNG GU
事業者登録番号
853-44-00368
所在地
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
電話
+82-10-4404-1523
メール
whitecalvin@tastedev.net
個人情報保護責任者
CHOI YOUNG GU

© 2026 TASTEDEV製品情報は検証済みの開発ソースに基づいています。リリース・改善中

Go ドキュメント
Go
Getting Started with GoSyntax BasicsTypes and DataModules and PackagesErrors and TestingKey Concepts: Concurrency
ディスカッション

Go ガイド · 4/6

Modules and Packages

この章は現在、英語でのみ提供しています。

Go splits code into packages and groups packages into versioned modules. This chapter covers go.mod and go.sum, visibility, dependencies, go install, and vendoring.

Modules: go.mod and go.sum

A module is a collection of packages that are released and versioned together. Its definition is the go.mod file at the module root, which records the module path, the Go language version the module targets, and the other modules it depends on.

module example.com/shop

go 1.xx // filled in by go mod init from your installed toolchain

require (
	github.com/google/uuid v1.6.0
	golang.org/x/sync v0.7.0 // indirect
)

The // indirect marker means your code does not import that module directly; something you depend on needs it. Treat the version numbers above as placeholders, since the tooling fills in real ones. Alongside go.mod sits go.sum, which stores cryptographic checksums of every module version you have downloaded. The go command verifies downloads against these hashes and, by default, against the public checksum database at sum.golang.org. Commit both files.

Packages and visibility

Each directory is one package, and its import path is the module path followed by the directory path. Visibility is controlled by capitalization alone: an identifier starting with an uppercase letter is exported and usable from other packages, while a lowercase one is private to its package. The rule applies uniformly to functions, types, variables, constants, struct fields, and methods.

// file: greet/greet.go
package greet

import "fmt"

// Hello is exported. Doc comments on exported names start with the name.
func Hello(name string) string {
	return fmt.Sprintf("%s, %s!", prefix(), name)
}

// prefix is visible only inside package greet.
func prefix() string { return "Hello" }

type Config struct {
	Lang  string // exported field
	debug bool   // unexported field
}
// file: main.go
package main

import (
	"fmt"

	"example.com/shop/greet"
)

func main() {
	fmt.Println(greet.Hello("gopher"))
	// greet.prefix() would not compile: it is unexported
}

Name packages with a short, lowercase word, and remember that callers always see the package name in front: greet.Hello reads well, while greet.GreetHello stutters. Import cycles, where package A imports B and B imports A, are rejected by the compiler. For packages that should only be shared within your own module, use the internal directory introduced in the first chapter.

Adding and upgrading dependencies

To use a third-party package, import it in your code and run go get or go mod tidy. tidy adds whatever your code imports and drops modules that nothing uses anymore, so it is a good habit to run it before committing.

この章について質問がありますか?
前の章Types and Data次の章Errors and Testing
# Add a dependency, or upgrade it to the newest release
go get github.com/google/uuid@latest

# Pin a specific version (downgrading works the same way)
go get github.com/google/uuid@v1.6.0

# Make go.mod and go.sum match the imports in your code
go mod tidy

# Inspect the dependency graph and available upgrades
go list -m all
go list -m -u all

# Remove a dependency
go get github.com/google/uuid@none

Modules follow semantic versioning. Starting at major version 2, the major version becomes part of the import path, as in example.com/lib/v2, so incompatible majors are treated as entirely separate packages. When several dependencies require different versions of the same module, Go uses minimal version selection: it picks the highest version that anyone explicitly requires, never something newer. Nothing upgrades behind your back.

go install

go install builds a package and places the binary in GOBIN, or in GOPATH/bin when GOBIN is unset. Adding a version suffix installs a tool in isolation, without touching the go.mod of whatever directory you happen to be in.

# Install a tool globally, independent of the current module
go install golang.org/x/tools/cmd/goimports@latest

# Install a main package from the module you are working on
go install ./cmd/server

# See where binaries end up
go env GOBIN GOPATH

Working on several modules at once

Sometimes you need to change a library and the application that uses it together, before the library is published. Two tools help. A replace directive in go.mod swaps a module for a local directory. A workspace, created with go work, groups several modules so they build together without editing any go.mod at all.

# replace: recorded in go.mod
go mod edit -replace example.com/lib=../lib

# workspace: creates go.work (usually kept out of version control)
go work init . ../lib

Vendoring basics

go mod vendor copies the source of every dependency needed for the build into a vendor directory at the module root. That helps when builds must run offline or dependency code must be reviewed in-repo. When a vendor directory exists and the module's go version is recent enough, go build uses it automatically.

go mod vendor          # writes vendor/ and vendor/modules.txt
go build -mod=vendor   # use vendor explicitly
go build -mod=mod      # ignore vendor and use the module cache

After changing dependencies, rerun go mod vendor to keep the directory in sync. Most projects never need vendoring; the module cache plus a module proxy (GOPROXY) is enough. For private repositories, list their paths in GOPRIVATE so the go command fetches them directly and skips the public proxy and checksum database.

Summary

  • go.mod records the module path and requirements, go.sum records checksums, and both are committed.
  • Capitalized names are exported; internal narrows visibility further.
  • Use go get module@version to add or change dependencies and go mod tidy to clean up.
  • go install path@version installs tools without touching your module.
  • go mod vendor copies dependencies into the repository; reach for it only when you need it.

コメント 0件

人気のコメント順新しい順

ログイン · ログインするとコメントできます。