Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Understand Go Modules / Go Modulesを理解する

linyows
February 12, 2019

Understand Go Modules / Go Modulesを理解する

Fukuoka.go#13 + Okayama.go で話した資料です。Feb 12, 2019

linyows

February 12, 2019
Tweet

More Decks by linyows

Other Decks in Programming

Transcript

  1. 'VLVPLBHP $ go test -v ./… -timeout 30s -parallel 8

    $ go build . $ go run main.go go: finding github.com/pierrec/lz4 v2.0.2+incompatible go: finding github.com/lestrrat-go/pdebug v0.0.0-20180220043849-39f9a71bcabe go: finding github.com/jessevdk/go-flags v1.4.0 go: finding github.com/dsnet/compress v0.0.0-20171208185109-cc9eb1d7ad76 go: finding github.com/mholt/archiver v0.0.0-20180417220235-e4ef56d48eb0 go: finding github.com/lestrrat-go/server-starter v0.0.0-20150105222616-88699d57aeee go: finding github.com/google/go-github v17.0.0+incompatible go: finding github.com/hashicorp/logutils v0.0.0-20150609070431-0dc08b1671f3 go: finding github.com/nwaples/rardecode v0.0.0-20171029023500-e06696f847ae go: finding github.com/carlescere/scheduler v0.0.0-20170109141437-ee74d2f83d82 go: finding github.com/pierrec/xxHash v0.1.1 … RUN ී௨ʹ࢖͏͚ͩͰཪͰ͍͍ײ͡ʹ΍ͬͯ͘ΕΔʢऴྃʣ
  2. 'VLVPLBHP # ґଘύοέʔδͷҰཡ $ go mod graph //or $ go

    list -m -f '{{.Version}}' all github.com/linyows/dewy github.com/pkg/[email protected] github.com/linyows/dewy github.com/pmezard/[email protected] github.com/linyows/dewy github.com/stretchr/[email protected] # ߋ৽͕Մೳͳύοέʔδόʔδϣϯͷදࣔ $ go list -u -m all | grep '\[.*\]' github.com/pkg/errors v0.8.0 [v0.8.1] github.com/pmezard/go-difflib v1.0.0 github.com/stretchr/testify v1.2.2 [v1.3.0] # Ұׅߋ৽ $ go get -u ґଘύοέʔδͷόʔδϣϯΛ্͛Δ
  3. 'VLVPLBHP # ґଘύοέʔδͷόʔδϣϯͷҰཡ $ go list -versions -m all github.com/pkg/errors

    v0.1.0 v0.2.0 v0.3.0 v0.4.0 v0.5.0 v0.5.1 v0.6.0 v0.7.0 v0.7.1 v0.8.0 v0.8.1 github.com/pmezard/go-difflib v1.0.0 github.com/dummy/log v1.1.1 v1.1.2 v1.1.3 v1.1.4 v1.2.0 v1.2.1 v1.2.2 v1.3.0 # ύοέʔδͷμ΢ϯάϨʔυ $ go get github.com/dummy/[email protected] # editίϚϯυ͔Β௥Ճ΍আ֎͕Ͱ͖Δʢgo.modͷߋ৽ʣ $ go mod edit -exclude github.com/dummy/[email protected] ໰୊ͷ͋ΔύοέʔδͷόʔδϣϯΛԼ͛Δ
  4. 'VLVPLBHP IUUQTHJUIVCDPNHPMBOHHPJTTVFTJTTVFDPNNFOU $ export GOBIN=$PWD/bin $ export PATH=$GOBIN:$PATH $ cat

    tools.go 1 // +build tools 2 package tools 3 4 import ( 5 _ "github.com/linyows/git-semv/cmd/git-semv" 6 ) $ go install github.com/linyows/git-semv/cmd/git-semv $ type git-semv /Users/linyows/projectx/bin/git-semv
  5. 'VLVPLBHP ๏ NPEVMF֎ͰNPEVMFૢ࡞͕Ͱ͖ΔΑ͏ʹͳͬͨʢHPHFU HPMJTU HPNPEEPXOMPBE͠ ͯ΋ॳظঢ়ଶΛҡ࣋͢Δʣ ๏ HPίϚϯυΛฒߦ࣮ߦ͕҆શʹͳͬͨʢpMFTZTUFN͕pMFMPDLJOHΛαϙʔτ͍ͯ͠Δ ඞཁ͕͋Δʣ ๏

    HPNPEʹHPόʔδϣϯσ ΟϨΫςΟϒͷαϙʔτʢͳ͚Ε͹DVSSFOUSFMFBTFΛ௥Ճ͢ Δ ๏ NPEVMFΛJNQPSUͰ͖ͳ͍৔߹ʹΩϟογϡ΍ωοτϫʔΫιʔεΑΓઌʹSFQMBDFͰ ࢦఆͨ͠ϩʔΧϧΛݟΔΑ͏ʹͳͬͨ .PEVMFTPG(P