最終更新日: 2026-07-25
TOP(About this memo)) > 一覧(Go) > モジュール・パッケージ
In Go, a function whose name starts with a capital letter can be called by a function not in the same package.
Go code is grouped into packages, and packages are grouped into modules
独自の中央モジュール パス レジストラを維持する必要がなくなり、衝突の可能性が排除されます。
toolchain go1.21.4
go mod edit -replace example.com/greetings=../greetings
go run . や go run hello.gogo help run 参照go run github.com/aaa/bbb/v3@latest --versiongo help buildgo build -work -a -p 1 -x main.go
go list -f '' で確認できるaaa
└ main.go
go help get参照go get -u ./...
go get モジュール名go get モジュール名@バージョンgo get -u モジュール名go mod tidyで解消する。% pwd
プロジェクトフォルダ/model
% go list
github.com/〜/model
% go list -m
github.com/〜
go list -m -u all
go help listThe -modcache flag causes clean to remove the entire module download cache, including unpacked source code of versioned dependencies
"gopls": {
"build.experimentalWorkspaceModule": true
}
replace (
github.com/ikawaha/kagome-dict/ipa => ../kagome-dict/ipa
)
import "github.com/google/go-cmp/cmp"のようになる。func f(w http.ResponseWriter, r *http.Request) {
server.Bind(r, &struct{}{})
emptycheck.EmptyCheck(&struct{}{})
}
emptycheck "github.com/megur0/empty-check" // エラーになる
"github.com/megur0/simple-server/server" // こっちは成功する
"github.com/megur0/empty-check/emptycheck"
"github.com/megur0/simple-server/server"