Slide 1

Slide 1 text

go1.22͔ΒͷςετΧόϨοδͱͷ෇͖߹͍ํ Go BASH 2024/06/18 גࣜձࣾΤϒϦʔ Ryoji Miyamoto

Slide 2

Slide 2 text

Copyright © 2015 every, Inc. All rights reserved. 2 • ࣗݾ঺հ • ΤϒϦʔͷ঺հ • go1.22͔ΒͷςετΧόϨοδͷ࢓༷มߋ • ͲͷΑ͏ͳٞ࿦͕͋ͬͨͷ͔ɺมΘͬͨഎܠΛ௥͏ • ࣮৘ʹ߹Θͤͯରॲͯ͠ΈΔ • ·ͱΊ ͓඼ॻ͖

Slide 3

Slide 3 text

Copyright © 2015 every, Inc. All rights reserved. 3 ࣗݾ঺հ {
 "name😀": "Ryoji Miyamoto",
 "team👥": "DEV_TTD_SE",
 "birthday🎂": "1994/08/22", "local🏠": "Ѫඤݝീ഼඿ࢢ",
 "career😎": {
 "2017/04": "ઍגࣜձࣾೖࣾ👻",
 "2020/12": "ΤϒϦʔೖࣾ🙌"
 },
 "like❤": [
 "ήʔϜ/Ξχϝ🎮",
 "όΠΫ/Ωϟϯϓ🛵🏕",
 "೔ຊञ🍶"
 ]
 }

Slide 4

Slide 4 text

4 ΤϒϦʔͷ঺հ

Slide 5

Slide 5 text

Copyright © 2015 every, Inc. All rights reserved. 5 ΤϒϦʔͷύʔύεɺϛογϣϯ ໌Δ͍มԽͷੵΈॏͳΔ฻Β͠Λɺ୭ʹͰ΋ɻ ʮwell-beingʢ΢ΣϧϏʔΠϯάʣʯ ͦͷ࣮ݱͷͨΊʹਓੜʹ͓͍ͯ୭΋͕࠷దͳબ୒ΛͰ͖Δ͔Ͳ͏͔͸ॏཁͰ͢ɻ ਐԽ͠ଓ͚ΔςΫϊϩδʔʹΑͬͯΦϯϥΠϯɾΦϑϥΠϯؔ܎ͳ͘ɺ ͞·͟·ͳ৘ใʹ৮ΕΔ͜ͱ͕Ͱ͖Δ࣌୅ɻ ΤϒϦʔ͸ɺσʔλɾAIΛ༻͍ͯ࠷దͳ৘ใΛͱͲ͚Δ͜ͱͰ ೔ʑͷੜ׆ʹ͓͚Δෆ҆΍೰ΈΛղফ͍ͨ͠ͱߟ͍͑ͯ·͢ɻ ࢲ͕ͨͪ໨ࢦ͢ͷ͸ɺਓ͕ຖ೔ΛาΉɺͦͷಓͷΓͷύʔτφʔͰ͋Δ͜ͱɻ Մೳੑ΍ؾ͖ͮΛ఻͑ɺͱ͖ʹ͸ࢥΘ͵ग़ձ͍Ͱɺؾ࣋ͪΛ๛͔ʹ͍ͯ͘͜͠ͱɻ Θͨͨͪ͠ΤϒϦʔ͸ɺ ͻͱΓͻͱΓͷ೔ৗʹɺલ޲͖ͳ͖͔͚ͬΛͱͲ͚͍͖ͯ·͢ɻ ୭ʹͰ΋ɺ໌Δ͍มԽͷੵΈॏͳΔ฻Β͕͠๚ΕΔΑ͏ʹɻ

Slide 6

Slide 6 text

Copyright © 2015 every, Inc. All rights reserved. 6 اۀ׆ಈΛ௨࣮ͯ͡ݱ͍ͨ͜͠ͱ

Slide 7

Slide 7 text

Copyright © 2015 every, Inc. All rights reserved. 7 ΤϒϦʔ͕ఏڙ͍ͯ͠ΔϓϩμΫτɺιϦϡʔγϣϯҰཡ

Slide 8

Slide 8 text

8 ຊ୊

Slide 9

Slide 9 text

Copyright © 2015 every, Inc. All rights reserved. 9 go 1.22ʹօ͞ΜΞϓσ͠·͔ͨ͠ʁ

Slide 10

Slide 10 text

Copyright © 2015 every, Inc. All rights reserved. 10 ͦͷ࣌ʹΧόϨοδԼ͕Γ·ͤΜͰ͔ͨ͠ʁ

Slide 11

Slide 11 text

Copyright © 2015 every, Inc. All rights reserved. 11 ͪͳΈʹτϞχςͷͱ͋ΔϦϙδτϦͰ΍ͬͨͱ͜Ζ

Slide 12

Slide 12 text

Copyright © 2015 every, Inc. All rights reserved. 12 ڻ͖ʹ70% OFFʂ

Slide 13

Slide 13 text

Copyright © 2015 every, Inc. All rights reserved. 13 go test -cover յΕͨʁ

Slide 14

Slide 14 text

Copyright © 2015 every, Inc. All rights reserved. 14 NO

Slide 15

Slide 15 text

Copyright © 2015 every, Inc. All rights reserved. 15 go1.22ͷϦϦʔεϊʔτʹ࢓༷มߋͷ͓࿩͋Γ·͢ʂ

Slide 16

Slide 16 text

Copyright © 2015 every, Inc. All rights reserved. 16 ϦϦʔεϊʔτͰͷ͓࿩ͷཁ໿ • Go 1.22Ҏ߱ɺςετϑΝΠϧͷͳ͍ύοέʔδͰ΋ΧόϨοδ͕දࣔ͞ΕΔ • ؔ਺͕Χόʔ͞Ε͍ͯͳ͍৔߹͸0.0%ѻ͍ • ࣮ߦՄೳͳίʔυ͕શ͘ͳ͍৔߹͸ɺʮςετϑΝΠϧ͕ͳ͍ʯͱใࠂ͞ΕΔ • ex.) ߏ଄ମ΍ΠϯλʔϑΣʔεͷఆٛͷΈͰؔ਺͕ͳ͍৔߹ͳͲ ~ go1.21 go1.22

Slide 17

Slide 17 text

Copyright © 2015 every, Inc. All rights reserved. 17 ςετΧόϨοδͷঢ়گΛΑΓৄࡉʹ೺ѲͰ͖ΔΑ͏ʹͳͬͨ

Slide 18

Slide 18 text

Copyright © 2015 every, Inc. All rights reserved. 18 ࠓճΧόϨοδ௿ԼͰݕग़͞Εͨ΋ͷ • ࣗಈੜ੒ܥͷ΋ͷ • ΤϯυϙΠϯτੜ੒(OpenAPI, GraphQLͷδΣωϨʔλ) • ORM • ҙਤతʹॻ͍ͯͳ͍࣮૷ • ςετ಺༰͕ςετίʔυ࡞੒࣌ͷ࿑ྗʹݟ߹ͬͯͳ͍΋ͷ • ඞཁͳςετ؀ڥ͕ෳࡶ • νʔϜ΍ϓϩδΣΫτن໛ʹΑͬͯ͸Skipͯ͠Δͱ͜Ζ

Slide 19

Slide 19 text

Copyright © 2015 every, Inc. All rights reserved. 19 • GOEXPERIMENT = nocoverageredesignΛ͚ͭΔ • ͨͩ༧ࠂͳ͘͜ͷࢦఆ͸Ͱ͖ͳ͘ͳΔՄೳੑ͸͋ΔͷͰকདྷੑ͸ո͍͠ • ྲྀੴʹҰ࣌͠ͷ͗ͳͷͰΑΖ͘͠ͳ͍ લͱಉ͡ڍಈʹ͢ΔͳΒ… GOEXPERIMENT=nocoverageredesign go test -cover ./...

Slide 20

Slide 20 text

Copyright © 2015 every, Inc. All rights reserved. 20 ࢓༷͕มΘͬͨͷ͸೺Ѳ͚ͨ͠ͲͳΜͰʁ

Slide 21

Slide 21 text

Copyright © 2015 every, Inc. All rights reserved. 21 • cmd/go: go test -cover & go test -coverprofile should always output a coverage #24570 • ΧόϨοδϨϙʔτͷग़ྗํࣜʹ͍ͭͯվળͷ༨஍͋Γͱ͍͏࿩ • ٞ࿦ࣗମ͸2018/03/18͔Β • ౰࣌͸go1.10࣌୅ • Go 1.10 Release Notes • ςετ݁ՌΛΩϟογϡ͢Δ • Ұ౓ʹෳ਺ύοέʔδͷΧόϨοδ͕औΕΔ ←͜͜ ىථ࣌ͷഎܠ

Slide 22

Slide 22 text

Copyright © 2015 every, Inc. All rights reserved. 22 • Ұ౓ʹෳ਺ύοέʔδͷΧόϨοδ͕औΕΔΑ͏ʹͳͬͨ • ͕ͩςετ͕ͳ͍΋ͷ͕ܭ্͞Ε͍ͯͳ͍ • ٯʹҰ౓Ͱ΋ର৅ͷؔ਺͕ςετ͞Ε͍ͯΕ͹ܭ্͞ΕΔ →ΧόϨοδ͸ܭଌൣғʹରͯ͠ͷશମͷׂ߹Λग़͍ͨ͠ Կ͕ٞ࿦ͷର৅ͱͳͬͨͷ͔

Slide 23

Slide 23 text

Copyright © 2015 every, Inc. All rights reserved. 23 • ςετϑΝΠϧͷͳ͍ύοέʔδʹ͍ͭͯΧόϨοδ(0%)Λग़ྗ͢Δ΂͖͔ • ग़ྗͨ͠ํ͕ະςετͷؔ਺͕͋Δ͜ͱ͕෼͔Γ΍͍͢ • ग़ྗ͠ͳ͍ͱ૯߹ΧόϨοδ཰͕ෆࣗવʹԼ͕Δ • ૯߹ΧόϨοδʹςετϑΝΠϧͷͳ͍ύοέʔδΛؚΊΔ΂͖͔ • ؚΊͨํ͕ະςετͷؔ਺͕໌֬ʹͳΔ ٞ࿦͞Ε͍ͯͨ͜ͱ 1/2

Slide 24

Slide 24 text

Copyright © 2015 every, Inc. All rights reserved. 24 • go test -coverͱgo test -coverprofileͰΧόϨοδग़ྗΛ౷Ұ͢Δ΂͖͔ • ౷Ұ͠ͳ͍ͱϢʔβʔʹࠞཚΛট͘Մೳੑ • ౷Ұ͢Δͱཁ݅ʹΑͬͯ͸ෆࣗવͳಈ࡞ʹͳΔՄೳੑ • ςετϑΝΠϧ͕ͳ͍=ະςετͳͷ͔ɺͦΕͱ΋୯ʹςετ͕ॻ͔Ε͍ͯͳ͍͚ͩͳͷ͔ • ະςετͱݟͳ͢΂͖͔ • ίʔυʹԠͯ͡൑அ͕෼͔ΕΔՄೳੑ • [no test files]ͱ0.0%ͷͲͪΒ͕ϢʔβʔʹͱͬͯΘ͔Γ΍͍͔͢ ٞ࿦͞Ε͍ͯͨ͜ͱ 2/2

Slide 25

Slide 25 text

Copyright © 2015 every, Inc. All rights reserved. 25 • ςετϑΝΠϧͷ༗ແʹؔΘΒͣʹશύοέʔδ͕ΧόϨοδϨϙʔτʹؚ·ΕΔΑ͏ʹ • go1.20Ҏ߱Ͱ͸ -coverpkg ϑϥάΛ͚ͭͨͱ͖ͷΈ • go1.22͔Βࢦఆͳ͠΋ద༻͞ΕΔΑ͏ʹͳͬͨ ࠷ऴతʹ

Slide 26

Slide 26 text

Copyright © 2015 every, Inc. All rights reserved. 26 എܠ͸׬શʹཧղͨ͠

Slide 27

Slide 27 text

Copyright © 2015 every, Inc. All rights reserved. 27 • ҙਤతʹςετͳ͍΋ͷΛΧόϨοδೖΕͨ͘͸ͳ͍ • ஫ࢹ͍ͨ͠ͷ͸ࣗ෼͕࣮ͨͪ૷͍ͯ͠Δ෦෼ • ϏδωεϩδοΫपΓ • ͦ΋ͦ΋ෆཁͳ΋ͷ·Ͱܭଌର৅ʹ͍ͯ͠Δͷ͕ྑ͘ͳ͍ • ࣗಈੜ੒ܥɺҙਤతʹॻ͍ͯͳ͍ͱ͜Ζ • Ҿ਺Ͱର৅pkg͸ࢦఆͯ͠ɺೖΕͨ͘ͳ͍΋ͷ͸আ֎͓ͯ͘͠ • go test -cover ./… → go test -cover pkg1 pkg2 ͜ͷมߋΛ౿·͑ͯ

Slide 28

Slide 28 text

Copyright © 2015 every, Inc. All rights reserved. 28 ΧόϨοδग़ྗํ๏Λݟ௚ͦ͏

Slide 29

Slide 29 text

Copyright © 2015 every, Inc. All rights reserved. 29 ςετϑΝΠϧ͕͋Δ΋ͷ͚ͩநग़͢Δ(ϗϫΠτϦετܕ) • ઐ༻ͷநग़εΫϦϓτ͔ΒߜΓࠐΉ • *_test.go͕͋ΔσΟϨΫτϦ͕ର৅ͱ͢Ε͹ࣗಈ ੜ੒ܥ͸ר͖ࠐ·Εͳ͍ • ϝϦοτ • جຊతʹैདྷ௨ΓͷڍಈʹͰ͖Δ • σϝϦοτ • ίʔυશମͷ࣭ΛଌΔ͏͑Ͱ͸Ӆṭ͞ΕΔ #!/bin/bash # ݱࡏͷσΟϨΫτϦ͔Β͢΂ͯͷGoύοέʔδΛݕࡧ for pkg in $(go list ./...); do # ֤ύοέʔδͷσΟϨΫτϦΛऔಘ pkg_dir=$(go list -f '{{.Dir}}' $pkg) # *_test.goϑΝΠϧ͕ͦͷσΟϨΫτϦʹଘࡏ͢Δ͔֬ೝ if [[ $(ls $pkg_dir/*_test.go 2> /dev/null) ]]; then # ଘࡏ͢Δ৔߹͸ύοέʔδ໊Λදࣔ echo $pkg fi done go test -cover $(./listup_test_pkg.sh)

Slide 30

Slide 30 text

Copyright © 2015 every, Inc. All rights reserved. 30 • আ֎ର৅pkgΛҰݩ؅ཧͯ͠ɺςετ࣌ʹআ֎͢Δ • ؅ཧํ๏͸yaml΍json౳ͷ͓޷͖ͳํͰ • pkg໊͕ύλʔϯԽͯ͠ΔͳΒهࡌ͸΋ͬͱָ • ϝϦοτ • আ֎͍ͨ͠΋ͷ͕໌ࣔత • ΧόϨοδܭଌͷҙຯͰ͸ݱ࣮త • σϝϦοτ • আ֎Օॴͷཏྻ͕໘౗Ͱखؒ আ֎͍ͨ͠pkgΛ໊ࢦ͢͠ΔʢϒϥοΫϦετܕʣ exclude_patterns=$(yq e '.ignore[]' testcnf.yml | sed 's/^/-e /' | tr '\n' ' ') go test -cover $(go list ./... | grep -vE $(echo $exclude_patterns)) ignore: - github.com/rymiyamoto/example-api/internal/app/ignore1 - github.com/rymiyamoto/example-api/internal/dashboard/ignore2 - github.com/rymiyamoto/example-api/internal/external/ignore3

Slide 31

Slide 31 text

Copyright © 2015 every, Inc. All rights reserved. 31 • go1.22͔ΒΦϓγϣϯࢦఆͳ͠Ͱ΋ςετͷ༗ແʹؔΘΒͣΧόϨοδ͕ग़ྗ͞ΕΔ • ΧόϨοδΛͲ͏ѻ͍͔ͬͯ͘ͷҙݟ͕༷ʑͳͷͰɺͲ͏͢Δ͔͸֤ࣗͷߟ͑ํ࣍ୈ • ࣗಈੜ੒෺Λ஄͖͍ͨͳΒɺςετର৅ՕॴͷΈΛࢦఆ͢Δඞཁ͕͋Δ ·ͱΊ

Slide 32

Slide 32 text

Copyright © 2015 every, Inc. All rights reserved. 32 • 7/2(Ր)ʹOPTiM͞ΜͱͷڞಉͰgoͷษڧձΛ։࠵͠·͢🎉 • https://optim.connpass.com/event/321331/ • ͜Μͳਓʹ͓͢͢Ί • Golang ʹڵຯ͕͋ΔΤϯδχΞ΍ֶੜͷํ • GolangͰͷ։ൃʹैࣄ͞Ε͍ͯΔํ • OPTiM ΍ every ͕ͲͷΑ͏ʹGolangΛ׆༻ͨ͠։ൃΛ͍ͯ͠Δͷ͔ڵຯ͕͋Δํ ΤϒϦʔ͔Βͷ͓஌Βͤ

Slide 33

Slide 33 text

Copyright © 2015 every, Inc. All rights reserved. 33 ΤϒϦʔ͔Βͷ͓஌Βͤ ҰॹʹαʔϏεΛ࡞Δ஥ؒΛେืूதͰ͢ʂ 🔍 ΤϒϦʔ ࠾༻ https://corp.every.tv/recruits ● Tech Blog΋΍ͬͯ·͢ ● ։ൃ෦ XΞΧ΢ϯτ ● ΤϒϦʔެࣜΦ΢ϯυϝσΟΞʮevery.thingʯ͸ͪ͜Β https://tech.every.tv/ https://everything.every.tv/ https://x.com/every_engineer

Slide 34

Slide 34 text

No content